jaydenseric / next-graphql-react

A graphql-react integration for Next.js.
https://npm.im/next-graphql-react
MIT License
77 stars 7 forks source link

SSG in Next 9.3 #4

Closed goodok21 closed 4 years ago

goodok21 commented 4 years ago

Hey! When I'm trying to run yarn export, got error:

> using build directory: /Users/user/Git/project/.next
  copying "static build" directory
> No "exportPathMap" found in "next.config.js". Generating map from "./pages"
> Info: Loaded env from .env
  launching 3 workers
  copying "public" directory
[ ===] Exporting (0/7)(node:4321) UnhandledPromiseRejectionWarning: TypeError: value.replace is not a function
at trim (/Users/user/Git/project/node_modules/http-link-header/lib/link.js:17:16)
    at Link.parse (/Users/user/Git/project/node_modules/http-link-header/lib/link.js:120:13)
    at new Link (/Users/user/Git/project/node_modules/http-link-header/lib/link.js:49:12)
    at /Users/user/Git/project/node_modules/next-graphql-react/universal/withGraphQLApp.js:117:42
(node:4321) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:4321) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

it's stuck in Exporting. Can anybody share example?

jaydenseric commented 4 years ago

I think it's because when Next.js does a static HTML export there is no server running, and the req and res in getInitialProps context is missing:

https://github.com/jaydenseric/next-graphql-react/blob/v6.0.1/src/universal/withGraphQLApp.mjs#L139

Probably the code should first check if res exists in the context before attempting to read from it.

I might be able to get some time in the next few days to add support for static HTML export, we'll see :)

jaydenseric commented 4 years ago

Thanks for your patience, the fix has been published 🎉