I have a graphql resolver in the server portion of Nuxt, and its endpoint stored in an env variable. It works nicely when called from the client, but blows up when called on the server side.
It is possible to work around this by supplying the full URL in the env variable, but this is impractical for scenarios where I need the environment to answer to multiple domain names.
Expected behaviour
I would expect to be able to call the local endpoint.
Reproduction
No response
Additional context
No response
Logs
`{
operation: {
variables: { language: 'sv' },
extensions: {},
operationName: 'schoolOptions',
query: { kind: 'Document', definitions: [Array], loc: [Location] }
},
networkError: TypeError: Failed to parse URL from /api/nuxt/graphql
at Object.fetch (node:internal/deps/undici/undici:11576:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
[cause]: TypeError [ERR_INVALID_URL]: Invalid URL
at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
at new NodeError (node:internal/errors:405:5)
at new URL (node:internal/url:611:13)
at new Request (node:internal/deps/undici/undici:7132:25)
at fetch2 (node:internal/deps/undici/undici:10715:25)
at Object.fetch (node:internal/deps/undici/undici:11574:18)
at fetch (node:internal/process/pre_execution:229:25)
at /home/filip/weahead/digitalist/unionen/frontend/node_modules/.pnpm/@nuxtjs+apollo@5.0.0-alpha.14_rollup@4.13.0_typescript@5.4.3_vue@3.4.21/node_modules/@apollo/client/link/http/createHttpLink.js:120:7
at new Subscription (/home/filip/weahead/digitalist/unionen/frontend/node_modules/.pnpm/zen-observable@0.8.15/node_modules/zen-observable/lib/Observable.js:197:34)
at Observable.subscribe (/home/filip/weahead/digitalist/unionen/frontend/node_modules/.pnpm/zen-observable@0.8.15/node_modules/zen-observable/lib/Observable.js:279:14)
at /home/filip/weahead/digitalist/unionen/frontend/node_modules/.pnpm/@nuxtjs+apollo@5.0.0-alpha.14_rollup@4.13.0_typescript@5.4.3_vue@3.4.21/node_modules/@apollo/client/link/context/index.js:20:45
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
input: '/api/nuxt/graphql',
code: 'ERR_INVALID_URL'
}
},
graphQLErrors: undefined,
forward: [Function (anonymous)]
}`
Environment
Describe the bug
I have a graphql resolver in the server portion of Nuxt, and its endpoint stored in an env variable. It works nicely when called from the client, but blows up when called on the server side.
It is possible to work around this by supplying the full URL in the env variable, but this is impractical for scenarios where I need the environment to answer to multiple domain names.
Expected behaviour
I would expect to be able to call the local endpoint.
Reproduction
No response
Additional context
No response
Logs