'Access-Control-Allow-Origin' header not being sent #406
-
I am getting a constant Cors header related error, despite the origin being set in the CorsLayer, is their something or multiple things i need to add or remove to fix this or is their something else i need to do to fix this issue
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I'm pretty sure all of those headers in the allow list are pointless except for content-type (which should be partially allowed by default, i.e. for some values). Your expose-headers also seem.. bogus. I would suggest to leave them off unless you are actually having trouble with reading a certain response header value. C.f. CORS-safelisted request header, CORS-safelisted response header. As to your actual problem, it's impossible to tell what's wrong without seeing what the request and response look like. Can you copy-paste the request and response headers from your browser's network tab? (in Firefox this is right click on a particular request > "Copy Value" > "Copy Request Headers" / "Copy Response Headers") |
Beta Was this translation helpful? Give feedback.
Oh, I didn't pick on up it before, but the problem is actually with your allowed origin, it's not a valid origin at all! An origin never includes the path. You just have to change to
.allow_origin("http://localhost:3000".parse::<HeaderValue>().unwrap())
.