I’m trying to deploy an apollo server to render.com with graphql subscriptions enabled. I have a local setup using docker/nginx with reverse proxies working: (server uses /graphql for both http and websocket)
// relevant part from the nginx.conf
location /graphql {
proxy_pass http://backend/graphql;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}
what would be the equivalent for a render.com “rewrite” ?
/graphql => https://my-backend-url.com/graphql won’t work
This post is migrated from slack, the discussion continued as bellow:
If I understand correctly, you have something like example.com which serves the frontend and you’d like to pass through example.com/graphql to backend.example.com/graphql?
Yes, exactly. This is a common pattern if you want to avoid CORS. (and your frontend and backend is in a different service)
One workaround for this is to use a dockerized service instead of a plain static site.
Also It would be nice to manage redirects and rewrites from code. sg like: https://docs.netlify.com/routing/redirects/#syntax-for-the-redirects-file
Netlify builds, deploys, and hosts your front end. Learn how to get started, see examples, and view documentation for the modern web platform. (16 kB)
@gergo what was the rewrite rule you tried? I think a /graphql -> https://…/graphql rule should work
@adrian unfortunately that doesn’t work