kamilkisiela / apollo-angular

A fully-featured, production ready caching GraphQL client for Angular and every GraphQL server 🎁
https://apollo-angular.com
MIT License
1.5k stars 309 forks source link

Angular SSR always fails on fetch with Invalid URL error #1928

Closed heddendorp closed 1 year ago

heddendorp commented 1 year ago

Describe the bug

When trying to fetch in SSR mode my request fails with a 500 Internal server error but that does not actually seem to be the case. The message is always Invalid URL but the request does work in the client.

To Reproduce

Steps to reproduce the behavior:

  1. clone https://github.com/heddendorp/apollo-angular-issue
  2. run npm i
  3. run npx run events:server
  4. run node dist/events/server/main.js
  5. Open local URL => see issue

Expected behavior

The request should work in both modes

Environment:

+-- @angular/cli@15.1.4
+-- @angular/core@15.1.3
+-- @apollo/client@3.7.7
+-- apollo-angular@4.2.1
+-- graphql@16.6.0
`-- typescript@4.8.4

Additional context

ApolloError: Http failure response for https://tumi.esn.world/graphql: 500 Internal Server Error
    at new ApolloError (C:\Users\hedde\code\gatorian\dist\events\server\main.js:1:5602658)
    at C:\Users\hedde\code\gatorian\dist\events\server\main.js:1:5653452
    at both (C:\Users\hedde\code\gatorian\dist\events\server\main.js:1:5596927)
    at C:\Users\hedde\code\gatorian\dist\events\server\main.js:1:5596783
    at new ZoneAwarePromise (C:\Users\hedde\code\gatorian\dist\events\server\main.js:1:4106848)
    at Object.then (C:\Users\hedde\code\gatorian\dist\events\server\main.js:1:5596738)
    at Object.error (C:\Users\hedde\code\gatorian\dist\events\server\main.js:1:5596976)
    at notifySubscription (C:\Users\hedde\code\gatorian\dist\events\server\main.js:1:5751769)
    at onNotify (C:\Users\hedde\code\gatorian\dist\events\server\main.js:1:5752362)
    at SubscriptionObserver2.error (C:\Users\hedde\code\gatorian\dist\events\server\main.js:1:5753815) {
  graphQLErrors: [],
  clientErrors: [],
  networkError: HttpErrorResponse {
    headers: HttpHeaders {
      normalizedNames: Map(0) {},
      lazyUpdate: null,
      lazyInit: [Function (anonymous)]
    },
    status: 500,
    statusText: 'Internal Server Error',
    url: 'https://tumi.esn.world/graphql',
    ok: false,
    name: 'HttpErrorResponse',
    message: 'Http failure response for https://tumi.esn.world/graphql: 500 Internal Server Error',
    error: { errors: [Array] }
  },
  extraInfo: undefined
}

I am happy to provide any more information and help with finding out more about this issue.