fastify / fastify-nextjs

React server side rendering support for Fastify with Next
Other
532 stars 61 forks source link

Throw error when use with next@13.4.3 #755

Closed joshuaavalon closed 1 year ago

joshuaavalon commented 1 year ago

Prerequisites

Fastify version

4.17.0

Plugin version

9.2.0

Node.js version

20.1.0

Operating system

Windows

Operating system version (i.e. 20.04, 11.3, 10)

10

Description

Error is thrown when next is updated to 13.4.3

- error uncaughtException: TypeError: Cannot read properties of undefined (reading 'nextConfig')
    at C:\Users\user\project\git\test1\node_modules\@fastify\nextjs\index.js:31:37

Steps to Reproduce

// index.js

import createFastify from "fastify";
import nextJs from "@fastify/nextjs";

const fastify = createFastify();
const nextPlugin = nextJs.default;

await fastify.register(nextPlugin);
fastify.after(() => {
  fastify.next("/hello");
});

fastify.listen({ port: 8001 }, (err) => {
  if (err) throw err;
  console.log("Server listening on http://localhost:3000");
});
{
  "name": "test1",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "start": "node index.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@fastify/nextjs": "^9.2.0",
    "fastify": "^4.17.0",
    "next": "^13.4.3"
  }
}

Expected Behavior

No error should be thrown.

joshuaavalon commented 1 year ago

See to related to vercel/next.js#50315