I am using nodejs express as my API in the backend. I wonder how to enable CORS on redirect
method.
Below is my express redirect code:
res.redirect(redirectUrl);
when client sends request to above API it will redirect the request to a s3
but I get below error:
Access to XMLHttpRequest at 'https://s3-ap-southeast-
2.amazonaws.com/index.html' (redirected from
'http://localhost:9090/v0/api') from origin 'http://localhost:9090' 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.
the frontend is running under http://localhost:9090
and the frontend domain has been added on CORS in the s3 bucket. It works fine if I send the request to https://s3-ap-southeast-2.amazonaws.com/index.html
directly from the browser. So I think the problem is on nodejs express redirect
method. How can I enable CORS for the redirect?
I know how to enable CORS
but my problem relates to redirect
. How can I make the redirect work?
from How to enable CORS on nodejs express redirect?
No comments:
Post a Comment