Skip to content
Advertisement

Access to fetch at ‘https://localhost:7144/api/employees’ from origin ‘http://localhost:3000’ has been blocked by CORS policy

Im getting this error when I try to fetch data from webapi to display in react js Here is a photo when I check the console this is what I get

here is my program.cs

JavaScript

here is one of my files employee.js

JavaScript

I believe the issue has to deal with the CORS Policy, but have tried everything. Does anything stand out to anyone? What should I do to prevent this and to display data from webapi to react?

Advertisement

Answer

you have to remove a trailing “/”, should be

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement