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
Attach Response Headers (or middlewares) to redirected requests (CORS issues) #3857
Comments
yashvardhan-kukreja
changed the title
Attach Response Headers (or middlewares) to redirected requests
Attach Response Headers (or middlewares) to redirected requests (CORS issues)
Feb 29, 2024
Raised the above PR #3858 as a resolution if the above issue is deemed worthy of having a solution. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
When the gin engine's tree is not aware of a path
/foo/
, instead of returning a 404, it responds plainly with a307 Location: /foo
(or 301 in case of GET) i.e. telling the client to redirect to/foo
There's no way to tell Gin what to do with such requests through the means any middlewares, like attaching CORS middlewares (a pretty commonly encountered case).
Some solutions I can think of:
engine.NoRoute(..,)
to explicitly define what happens at NotFound."/"
to all the incoming requests, including redirect request.How to reproduce
Expectations
Open a new tab in the browser and open dev tools there.
Go to the "Console", and run the following code
Expectation
Actual result
Environment
The text was updated successfully, but these errors were encountered: