-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lack of Origin Header Results in 403 Even When AllowOrigins is set to "*" #2667
Comments
Issue #2534 may be the same underlying problem, but I'm unsure. |
I can not test this ATM but looking at CORS middleware code (https://github.com/labstack/echo/blob/master/middleware/cors.go) I can not find line where 403 is being returned. Do you mean 203? It would be nice if you could copy/paste example of that handshake request here with headers etc. |
I think your problem is with there is a comment there // Handler is a simple interface to a WebSocket browser client.
// It checks if Origin header is valid URL by default.
// You might want to verify websocket.Conn.Config().Origin in the func.
// If you use Server instead of Handler, you could call websocket.Origin and
// check the origin in your Handshake func. So, if you want to accept
// non-browser clients, which do not send an Origin header, set a
// Server.Handshake that does not check the origin. |
Yeah, you are correct, this does seem to be the source of the issue. Thank you! |
Issue Description
The default CORS configuration for echo sets AllowOrigins to the wildcard, "*", which should allow requests to be made regardless of origin. However, when we were switching over from
x/net/websocket
tonhooyr/websocket
on the client side, we noticed that if the client doesn't send an Origin header, the request will be denied with a 403.We discovered this because while
x/net/websocket
requires an origin be set when calling itsDial
function,nhooyr/websocket
has no such requirement.I also opened a related documentation, etc. issue on the websocket library here
Checklist
Expected behaviour
If AllowOrigins is set to *, then the absence of the Origin header will not result in a 403 status code.
Actual behaviour
Lack of an Origin header will always result in a 403 even if any origin is allowed.
Steps to reproduce
Working code to debug
Server
Client
Version/commit
v4.12.0
The text was updated successfully, but these errors were encountered: