![]() |
blocked by CORS policy - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: blocked by CORS policy (/showthread.php?tid=90671) |
blocked by CORS policy - lucascortes - 04-15-2024 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. RE: blocked by CORS policy - kenjis - 04-15-2024 See https://codeigniter4.github.io/CodeIgniter4/libraries/cors.html |