Skip to content
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

Relative API url doesn't work with SSR #610

Open
filiphazardous opened this issue Apr 4, 2024 · 1 comment
Open

Relative API url doesn't work with SSR #610

filiphazardous opened this issue Apr 4, 2024 · 1 comment
Labels

Comments

@filiphazardous
Copy link
Contributor

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

`{
  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/@[email protected][email protected][email protected][email protected]/node_modules/@apollo/client/link/http/createHttpLink.js:120:7
        at new Subscription (/home/filip/weahead/digitalist/unionen/frontend/node_modules/.pnpm/[email protected]/node_modules/zen-observable/lib/Observable.js:197:34)
        at Observable.subscribe (/home/filip/weahead/digitalist/unionen/frontend/node_modules/.pnpm/[email protected]/node_modules/zen-observable/lib/Observable.js:279:14)
        at /home/filip/weahead/digitalist/unionen/frontend/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/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)]
}`
@pixleight
Copy link

Also interested in this. Seems to be related (or duplicate?) of #507 , so this appears to have been an issue for quite some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants