-
Notifications
You must be signed in to change notification settings - Fork 24
Use native nextjs proxy for graphql #131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
next.config.js
Outdated
| return [ | ||
| { | ||
| source: "/api/graphql", | ||
| destination: "http://localhost:8080/query", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the GUAC GQL server is running somewhere else? Should we be checking for the value of GUACGQL_SERVER_URL here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wait. I haven't had coffee yet. This is probably what you meant by "The remaining issue in this PR is that the query URL should come from src/config.ts, but this would require converting the next config to typescript." 😄
So assuming we merge this now, what's the failure case when the server is running somewhere else? It seems like src/config.ts already checks for the GUACGQL_SERVER_URL environment variable, so we should be able to lean on that, I think. I'm not very familiar with Javascript and friends, I'm more of a sysadmin type, so forgive me if I'm missing something obvious.
|
Hi,Yes, the query URL is currently defined in config.ts. Ideally, there remains a single source of truth for the query URL. As it is a typescript file, we can’t currently import the query in the next JS config.The solution I proposed is to convert the JS next config to TS, which allows importing from the config.ts. I was asking this would indeed be the appropriate thing to do.If so, I’ll update this PR with that change.
|
|
After some digging, it turns out that v14 of next does not support TS config files. To keep the URLs in the central config, I needed to convert |
|
Trying to test it locally, I'm getting this error: I'm not a JavaScript person, so this could be user error, but I haven't been able to find a solution. |
|
This is caused by the import of console in config.js.Since this file is used by both frontend (browser) as well as next (node) this results in an error. Luckily console is available without importing it, as it is a global. I’ll fix the PR. Op 19 feb 2025 om 16:09 heeft Ben Cotton ***@***.***> het volgende geschreven:
Trying to test it locally, I'm getting this error:
○ Compiling / ...
⨯ node:console
Module build failed: UnhandledSchemeError: Reading from "node:console" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
Import trace for requested module:
node:console
./src/config.js
./apollo/client.ts
./app/page.tsx
I'm not a JavaScript person, so this could be user error, but I haven't been able to find a solution.—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
funnelfiasco left a comment (guacsec/guac-visualizer#131)
Trying to test it locally, I'm getting this error:
○ Compiling / ...
⨯ node:console
Module build failed: UnhandledSchemeError: Reading from "node:console" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
Import trace for requested module:
node:console
./src/config.js
./apollo/client.ts
./app/page.tsx
I'm not a JavaScript person, so this could be user error, but I haven't been able to find a solution.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Signed-off-by: Hidde-Jan Jongsma <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I don't have write access on this repo, so it doesn't "count", but I'll ask the maintainers to take a look. Thanks again @hidde-jan!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Currently the proxy for proxying graphql requests is implemented as a page. On my machine, this causes intermittent 500 errors, see guacsec/guac#2494
Next offers native proxy capabilities. Using that capability solves the intermittent issues for me. It also seems like it improves performance.
The remaining issue in this PR is that the query URL should come from
src/config.ts, but this would require converting the next config to typescript.