netflix dgs graphql with nginx

when dgs is running behind a reverse proxy, the graphiql is not working:

Expected behavior

When dgs is accessed directly, the graphiql is working.


When dgs is accessed from reverse proxy, the graphiql should work as well.

Actual behavior

When dgs is accessed from reverse proxy, the graphiql stopped working.


Steps to reproduce

  1. set up nginx as a reverse proxy, point /data to the backend dgs service (assume it’s dataprovider)
  2. access graphiql from http://<nginx_server>/data/graphiql

Note: A test case would be highly appreciated, but we understand that’s not always possible

Some RCA

The issue is due to in graphiql, its trying to fetch the graphql path as absolute path:

this would assume the graphql is at the root, which won’t be true with an existence of reverse proxy.

Possible Solution

The solution is to change that path to a relative path as ./graphql.

Isuse:

https://github.com/Netflix/dgs-framework/issues/1203

The fix is to point dgs graphiql at the relative path instead of root:

PR: https://github.com/Netflix/dgs-framework/pull/1204

With MR: #1204, and bump dgs version to 5.2.1, it’s now working both w/ and w/o reverse proxy.

w/


w/o


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s