blocked by CORS policy |
I created a restful api with codeigniter 4, but when I make a request through the browser, I get the following error: "Access to XMLHttpRequest at 'http://localhost:3001/v1/pessoa' from origin 'http:// localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.".
But when I test it through postman, it works correctly. What should be done to correct it? I already tried to create a filter, as suggested on the internet, but it didn't work. In the frontend I make a request and in the network tab of devtools, two requests appear, one is Options and it was giving 404, so I created a method in my control and defined this route to Options, so this first option responded ok, but the GET method continues 404 (GET + preflight), how do I resolve this situation, someone please help me. |
Welcome Guest, Not a member yet? Register Sign In |