Closed vikkio88 closed 4 years ago
I went to dig on the code and found out that the middleware is applying cors only if the header Origin
is setup on the request, that is why it want appearing by default.
% curl -H origin:somestuff.com localhost:3000/ping
...
Access-Control-Allow-Origin: *
...
so not a bug but a feature
maybe is worth adding it on the docs, to avoid confusing newbies like myself
Hello there, new to go so I am learning as I go sort of translating a small api app from other languages.
I will need to have cors, so rather than building my own middleware, I thought to give this a go, but looks like something is not working properly, maybe
gin
changed the way middlewares are provided? can't see anything around not even on the issues.basically my code looks like this
and I expect this to return the Allow Origins Headers, but I only get this
am I doing something wrong? In the example you can only see the middleware being
Use
d by the router, not the example route, I tried to place it before, and after the middleware declaration, but still nothing.What am I doing wrong? Maybe is worth updating the doc to showcase an example with a route call?
thanks in advance