Lets say I have a site at myapp.com that talks to the api at myapi.com. For that to work I have to turn on CORS. I want to do it like that:
Access-Control-Allow-Origin: *
and my API authentication is performed via a custom Authorize header (with e.g. Bearer token).
As far as I can see it is safe to do since an attacker website would have a way of obtaining this token or sending it automatically.
Is this correct?
P.S. I want to have a "*" to e.g. not have problems with localhost development or some other environments where myapp.com runs, e.g. stage-myapp.com, etc.
Access-Control-Allow-Origin: *but because you are unable to setup a properDevelopment environmentyou want to lower the protection offered by this header. I would suggest trying to solve the actuall problem (getting a proper dev environment) instead of abbusing a header for this. – LvB Sep 21 '20 at 11:06Access-Control-Allow-Origin: *can, in some contexts, be insecure. – jub0bs Mar 16 '23 at 21:09