Open kovalenp opened 1 year ago
Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.
hello @kovalenp How did you resolve this issue? Thanks in advance.
@amitkTechno I didn't. You can remove /*
route (if logic of your app allows to do so) and it will work, alternatively you could set the cors headers yourself
I managed to fix this by adding the prefix
option:
await server.register(proxyPlugin, {
prefix: "/api",
upstream: "http://localhost:3002",
});
However, this does mean that now your clients will have to access the proxied server over the /api
path.
Prerequisites
Fastify version
4.5.3
Plugin version
9.2.1
Node.js version
16.15.1
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
13.4
Description
I need to allow CORS for my Fastify application. To achieve this I'm using
@fastify/cors
package with following settings:if I register the http-proxy route for something like this:
I will get an error:
Probably because of this part of the lib:
Steps to Reproduce
Register
fastify/cors
withfastify/fastify-http-proxy
for all routesExpected Behavior
There is a way to enable cors on all routes for http-proxy plugin
PS:
I tried something like:
but it didn't do the trick for me