Rob--W / cors-anywhere

CORS Anywhere is a NodeJS reverse proxy which adds CORS headers to the proxied request.
MIT License
8.5k stars 5.92k forks source link

cors anywhere not working on vercel #478

Closed SanjaySRocks closed 5 months ago

SanjaySRocks commented 5 months ago

I have successfully deployed cors anywhere on vercel but its not working when i send a request from client I get error in client console

Access to fetch at 'https://xxxxxx-proxy.vercel.app/https://xxxxx/api/learner/subject_api.php' from origin 'http://127.0.0.1:5500' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.
script.js:25 

POST https://cors-proxy-olive-one.vercel.app/https://xxxxx/api/learner/subject_api.php net::ERR_FAILED
getTimetable @ script.js:25

How can I fix it?

Rob--W commented 5 months ago

CORS Anywhere does not redirect on preflight requests. It immediately responds with a 200 OK+CORS headers: https://github.com/Rob--W/cors-anywhere/blob/70aaa22b3f9ad30c8566024bf25484fd1ed9bda9/lib/cors-anywhere.js#L304-L310

The response you are observing is not generated by CORS Anywhere. To debug it, I suggest to check the browsers developer tools to inspect the network traffic, and perhaps use curl to simulate the network requests without getting blocked by the browser.