You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the gin engine's tree is not aware of a path /foo/ , instead of returning a 404, it responds plainly with a 307 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:
Have a way to define what happens on redirect like we currently do with engine.NoRoute(..,) to explicitly define what happens at NotFound.
Access to fetch at 'http://localhost:9000/foo/' from origin 'chrome-extension://pejkokffkapolfffcgbmdmhdelanoaih' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Environment
go version: 1.22.0
gin version (or commit ref): 1.9.1
operating system: MacOS (Darwin ARM64)
The text was updated successfully, but these errors were encountered:
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
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: