opennextjs / opennextjs-netlify

Open Next.js adapter for Netlify
https://opennext.js.org/netlify
665 stars 86 forks source link

[Bug]: 404 page for static routes using getStatic... #2043

Closed alianza closed 1 year ago

alianza commented 1 year ago

Summary

My next.js site started showing 404's for dynamic routes using getStaticPaths and getStaticProps. Also nested routes like /blog/article throw a 404. This seems to be related to this issue on Netlify forums: https://answers.netlify.com/t/nextjs-routes-404-on-successful-build/89630 But I couldn't find any trackable issue for it.

I was able to resolve some of the 404's by adding fallback: 'blocking' to getStaticPaths but routes only using getStaticProps are still broken. https://github.com/alianza/portfolio-lea/commit/75b6d2dd3a749744bc16cdca1e8997e890b3ddc4

Steps to reproduce

  1. Go to https://643943e04d55480008006036--portfolio-lea.netlify.app/
  2. Click on a blog post, or click on a category or the all categories page
  3. Observe 404

A link to a reproduction repository

https://github.com/alianza/portfolio-lea

Next Runtime version

v4.34.0

Is your issue related to the app directory (beta)?

More information about your build

What OS are you using?

Windows

Your netlify.toml file

`netlify.toml` ```toml [functions] included_files = ["content/**"] # Include the content directory for Netlify functions (ISR) ```

Your public/_redirects file

`_redirects` ``` # Paste content of your `_redirects` file here ```

Your next.config.js file

`next.config.js` ```js const prod = process.env.NODE_ENV === 'production'; const withBundleAnalyzer = require('@next/bundle-analyzer')({ enabled: process.env.ANALYZE === 'true', }); const withPWA = require('next-pwa')({ dest: 'public', disable: !prod, // buildExcludes: [/middleware-manifest\.json$/] }); const nextConfig = { }; module.exports = withBundleAnalyzer( withPWA({ ...nextConfig, }) ); ```

Builds logs (or link to your logs)

Build logs ``` 2:15:31 PM: build-image version: 442a909cc19725b67a71cc230a935e063dadf683 (focal) 2:15:31 PM: buildbot version: 716793686322a0f551ced71ae75eb84b472ba215 2:15:31 PM: Fetching cached dependencies 2:15:31 PM: Starting to download cache of 874.3MB 2:15:37 PM: Finished downloading cache in 5.786s 2:15:37 PM: Starting to extract cache 2:15:41 PM: Finished extracting cache in 3.615s 2:15:41 PM: Finished fetching cache in 9.489s 2:15:41 PM: Starting to prepare the repo for build 2:15:41 PM: Preparing Git Reference refs/heads/main 2:15:41 PM: Parsing package.json dependencies 2:15:43 PM: Starting to install dependencies 2:15:43 PM: Python version set to 3.8 2:15:43 PM: Attempting Ruby version 2.7.2, read from environment 2:15:44 PM: Using Ruby version 2.7.2 2:15:44 PM: Started restoring cached go cache 2:15:44 PM: Finished restoring cached go cache 2:15:44 PM: Installing Go version 1.19.5 (requested 1.19.5) 2:15:49 PM: go version go1.19.5 linux/amd64 2:15:49 PM: Using PHP version 8.0 2:15:50 PM: Started restoring cached Node.js version 2:15:50 PM: Finished restoring cached Node.js version 2:15:50 PM: v16.20.0 is already installed. 2:15:51 PM: Now using node v16.20.0 (npm v8.19.4) 2:15:51 PM: Enabling Node.js Corepack 2:15:51 PM: Started restoring cached build plugins 2:15:51 PM: Finished restoring cached build plugins 2:15:51 PM: Started restoring cached corepack dependencies 2:15:51 PM: Finished restoring cached corepack dependencies 2:15:51 PM: Started restoring cached yarn cache 2:15:52 PM: Finished restoring cached yarn cache 2:15:53 PM: Installing Yarn version 1.22.10 2:15:53 PM: Preparing yarn@1.22.10 for immediate activation... 2:15:53 PM: No yarn workspaces detected 2:15:53 PM: Started restoring cached node modules 2:15:53 PM: Finished restoring cached node modules 2:15:53 PM: Installing npm packages using Yarn version 1.22.10 2:15:53 PM: yarn install v1.22.10 2:15:53 PM: [1/4] Resolving packages... 2:15:54 PM: success Already up-to-date. 2:15:54 PM: Done in 0.20s. 2:15:54 PM: npm packages installed using Yarn 2:15:54 PM: Install dependencies script success 2:15:54 PM: Starting build script 2:15:55 PM: Detected 1 framework(s) 2:15:55 PM: "next" at version "13.3.0" 2:15:55 PM: Section completed: initializing 2:15:56 PM: ​ 2:15:56 PM: Netlify Build 2:15:56 PM: ──────────────────────────────────────────────────────────────── 2:15:56 PM: ​ 2:15:56 PM: ❯ Version 2:15:56 PM: @netlify/build 29.9.1 2:15:56 PM: ​ 2:15:56 PM: ❯ Flags 2:15:56 PM: baseRelDir: true 2:15:56 PM: buildId: 643943e04d55480008006034 2:15:56 PM: deployId: 643943e04d55480008006036 2:15:56 PM: ​ 2:15:56 PM: ❯ Current directory 2:15:56 PM: /opt/build/repo 2:15:56 PM: ​ 2:15:56 PM: ❯ Config file 2:15:56 PM: /opt/build/repo/netlify.toml 2:15:56 PM: ​ 2:15:56 PM: ❯ Context 2:15:56 PM: production 2:15:56 PM: ​ 2:15:56 PM: ❯ Using Next.js Runtime - v4.34.0 2:15:58 PM: ​ 2:15:58 PM: 1. @netlify/plugin-nextjs (onPreBuild event) 2:15:58 PM: ──────────────────────────────────────────────────────────────── 2:15:58 PM: ​ 2:15:58 PM: Next.js cache restored. 2:15:58 PM: Netlify configuration property "build.environment.NEXT_PRIVATE_TARGET" value changed. 2:15:58 PM: ​ 2:15:58 PM: (@netlify/plugin-nextjs onPreBuild completed in 56ms) 2:15:58 PM: ​ 2:15:58 PM: 2. Build command from Netlify app 2:15:58 PM: ──────────────────────────────────────────────────────────────── 2:15:58 PM: ​ 2:15:58 PM: $ yarn build 2:15:58 PM: yarn run v1.22.10 2:15:58 PM: $ run-p build-cms-styles copy-config next:build 2:15:58 PM: $ run-p build-styles:* 2:15:58 PM: $ copy-and-watch content/config.json public/ 2:15:58 PM: $ next build 2:15:58 PM: [COPY] content/config.json to public/config.json 2:15:58 PM: $ sass ./styles/_variables.scss ./public/styles/variables.css --no-source-map 2:15:58 PM: $ sass components/mdContent/mdContent.module.scss ./public/styles/content.module.css --no-source-map 2:15:59 PM: info - Linting and checking validity of types... 2:15:59 PM: info - Creating an optimized production build... 2:15:59 PM: > [PWA] Compile client (static) 2:15:59 PM: > [PWA] Auto register service worker with: /opt/build/repo/node_modules/next-pwa/register.js 2:15:59 PM: > [PWA] Service worker: /opt/build/repo/public/sw.js 2:15:59 PM: > [PWA] url: /sw.js 2:15:59 PM: > [PWA] scope: / 2:15:59 PM: > [PWA] Fallback to precache routes when fetch failed from cache or network: 2:15:59 PM: > [PWA] document (page): /_offline 2:15:59 PM: > [PWA] Compile server 2:15:59 PM: > [PWA] Compile server 2:16:03 PM: Browserslist: caniuse-lite is outdated. Please run: 2:16:03 PM: npx update-browserslist-db@latest 2:16:03 PM: Why you should do it regularly: https://github.com/browserslist/update-db#readme 2:16:06 PM: info - Compiled successfully 2:16:06 PM: info - Collecting page data... 2:16:07 PM: info - Generating static pages (0/22) 2:16:07 PM: info - Generating static pages (5/22) 2:16:07 PM: info - Generating static pages (10/22) 2:16:07 PM: info - Generating static pages (16/22) 2:16:10 PM: info - Generating static pages (22/22) 2:16:10 PM: info - Finalizing page optimization... 2:16:10 PM: Route (pages) Size First Load JS 2:16:10 PM: ┌ ● / (ISR: 60 Seconds) (2410 ms) 5.28 kB 91.5 kB 2:16:10 PM: ├ └ css/68f4179873b7bd6f.css 2.88 kB 2:16:10 PM: ├ /_app 0 B 77.2 kB 2:16:10 PM: ├ ○ /_offline 378 B 77.5 kB 2:16:10 PM: ├ ○ /404 182 B 77.3 kB 2:16:10 PM: ├ ● /about 378 B 89 kB 2:16:10 PM: ├ ● /articles (ISR: 60 Seconds) (487 ms) 1.59 kB 92.4 kB 2:16:10 PM: ├ ● /blog 1.25 kB 92 kB 2:16:10 PM: ├ ● /blog/[postId] 706 B 89.4 kB 2:16:10 PM: ├ ├ /blog/2022-10-24_capturing-birds-in-the-wild 2:16:10 PM: ├ ├ /blog/2023-01-05_a-collection-of-haikus 2:16:10 PM: ├ └ /blog/2023-01-05_mind-over-matter 2:16:10 PM: ├ ● /blog/categories 885 B 89.5 kB 2:16:10 PM: ├ ● /blog/categories/[name] (303 ms) 4.49 kB 90.7 kB 2:16:10 PM: ├ ├ /blog/categories/Poetry 2:16:10 PM: ├ ├ /blog/categories/Photography 2:16:10 PM: ├ ├ /blog/categories/Reflections 2:16:10 PM: ├ └ /blog/categories/Fiction 2:16:10 PM: ├ ● /contact 703 B 89.4 kB 2:16:10 PM: ├ └ css/e23c74de4635b200.css 2.59 kB 2:16:10 PM: ├ ● /portfolio 1.13 kB 91.9 kB 2:16:10 PM: └ ● /portfolio/[experienceId] (310 ms) 712 B 89.4 kB 2:16:10 PM: ├ /portfolio/05-01-2023_essay-skate-mag-—-writer 2:16:10 PM: ├ /portfolio/2022-04-21_internship-at-dutch-review 2:16:10 PM: ├ /portfolio/2022-10-25_bachelor-of-arts-in-media-and-information-at-the-university-of-amsterdam 2:16:10 PM: └ [+2 more paths] 2:16:10 PM: + First Load JS shared by all 80.5 kB 2:16:10 PM: ├ chunks/framework-2c79e2a64abdb08b.js 45.2 kB 2:16:10 PM: ├ chunks/main-7ffe718e72223f79.js 29.3 kB 2:16:10 PM: ├ chunks/pages/_app-b3dcbd950e938655.js 350 B 2:16:10 PM: ├ chunks/webpack-d5b46b782a733c2e.js 2.27 kB 2:16:10 PM: └ css/33ef4568ec6ebbf6.css 3.31 kB 2:16:10 PM: ○ (Static) automatically rendered as static HTML (uses no initial props) 2:16:10 PM: ● (SSG) automatically generated as static HTML + JSON (uses getStaticProps) 2:16:10 PM: (ISR) incremental static regeneration (uses revalidate in getStaticProps) 2:16:10 PM: Done in 12.27s. 2:16:10 PM: ​ 2:16:10 PM: (build.command completed in 12.4s) 2:16:10 PM: ​ 2:16:10 PM: 3. @netlify/plugin-nextjs (onBuild event) 2:16:10 PM: ──────────────────────────────────────────────────────────────── 2:16:10 PM: ​ 2:16:10 PM: Patching /opt/build/repo/node_modules/next/dist/server/base-server.js 2:16:10 PM: Done 2:16:10 PM: Patching /opt/build/repo/node_modules/next/dist/server/next-server.js 2:16:10 PM: Done 2:16:10 PM: Moving static page files to serve from CDN... 2:16:10 PM: Moved 0 files 2:16:10 PM: You are not using Netlify Edge Functions for image format detection. Set env var "NEXT_FORCE_EDGE_IMAGES=true" to enable. 2:16:10 PM: Netlify configuration property "redirects" value changed to [ 2:16:10 PM: { from: '/_next/static/*', to: '/static/:splat', status: 200 }, 2:16:10 PM: { 2:16:10 PM: from: '/_next/image*', 2:16:10 PM: query: { url: ':url', w: ':width', q: ':quality' }, 2:16:10 PM: to: '/_ipx/w_:width,q_:quality/:url', 2:16:10 PM: status: 301 2:16:10 PM: }, 2:16:10 PM: { from: '/_ipx/*', to: '/.netlify/builders/_ipx', status: 200 }, 2:16:10 PM: { from: '/cache/*', to: '/404.html', status: 404, force: true }, 2:16:10 PM: { from: '/server/*', to: '/404.html', status: 404, force: true }, 2:16:10 PM: { from: '/serverless/*', to: '/404.html', status: 404, force: true }, 2:16:10 PM: { from: '/trace', to: '/404.html', status: 404, force: true }, 2:16:10 PM: { from: '/traces', to: '/404.html', status: 404, force: true }, 2:16:10 PM: { 2:16:10 PM: from: '/routes-manifest.json', 2:16:10 PM: to: '/404.html', 2:16:10 PM: status: 404, 2:16:10 PM: force: true 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/build-manifest.json', 2:16:10 PM: to: '/404.html', 2:16:10 PM: status: 404, 2:16:10 PM: force: true 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/prerender-manifest.json', 2:16:10 PM: to: '/404.html', 2:16:10 PM: status: 404, 2:16:10 PM: force: true 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/react-loadable-manifest.json', 2:16:10 PM: to: '/404.html', 2:16:10 PM: status: 404, 2:16:10 PM: force: true 2:16:10 PM: }, 2:16:10 PM: { from: '/BUILD_ID', to: '/404.html', status: 404, force: true }, 2:16:10 PM: { 2:16:10 PM: from: '/api/*', 2:16:10 PM: to: '/.netlify/functions/___netlify-handler', 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/android-chrome-192x192.png', 2:16:10 PM: to: '/android-chrome-192x192.png', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/android-chrome-256x256.png', 2:16:10 PM: to: '/android-chrome-256x256.png', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/android-chrome-512x512.png', 2:16:10 PM: to: '/android-chrome-512x512.png', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/apple-touch-icon.png', 2:16:10 PM: to: '/apple-touch-icon.png', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/browserconfig.xml', 2:16:10 PM: to: '/browserconfig.xml', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/config.json', 2:16:10 PM: to: '/config.json', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/fallback-102vwDfM1oq7ReG-VTo1T.js', 2:16:10 PM: to: '/fallback-102vwDfM1oq7ReG-VTo1T.js', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/favicon-16x16.png', 2:16:10 PM: to: '/favicon-16x16.png', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/favicon-32x32.png', 2:16:10 PM: to: '/favicon-32x32.png', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/favicon.ico', 2:16:10 PM: to: '/favicon.ico', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/mstile-150x150.png', 2:16:10 PM: to: '/mstile-150x150.png', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/safari-pinned-tab.svg', 2:16:10 PM: to: '/safari-pinned-tab.svg', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/site.webmanifest', 2:16:10 PM: to: '/site.webmanifest', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/sw.js', 2:16:10 PM: to: '/sw.js', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/workbox-6a1bf588.js', 2:16:10 PM: to: '/workbox-6a1bf588.js', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/admin/cms_img.jpg', 2:16:10 PM: to: '/admin/cms_img.jpg', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/admin/config.yml', 2:16:10 PM: to: '/admin/config.yml', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/admin/index.html', 2:16:10 PM: to: '/admin/index.html', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/10610_3707769300997_775215996_n.jpg', 2:16:10 PM: to: '/images/10610_3707769300997_775215996_n.jpg', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/124010.png', 2:16:10 PM: to: '/images/124010.png', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/3987-17.jpg', 2:16:10 PM: to: '/images/3987-17.jpg', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/3987-32.jpg', 2:16:10 PM: to: '/images/3987-32.jpg', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/3987-33.jpg', 2:16:10 PM: to: '/images/3987-33.jpg', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/5ecec78673e4440004f09e77-1-.png', 2:16:10 PM: to: '/images/5ecec78673e4440004f09e77-1-.png', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/855f884b4e10d23500.jpeg', 2:16:10 PM: to: '/images/855f884b4e10d23500.jpeg', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/articl1.png', 2:16:10 PM: to: '/images/articl1.png', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/articl2.png', 2:16:10 PM: to: '/images/articl2.png', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/articl4.png', 2:16:10 PM: to: '/images/articl4.png', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/ayatakano.jpeg', 2:16:10 PM: to: '/images/ayatakano.jpeg', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/iconmonstr-medium-1.png', 2:16:10 PM: to: '/images/iconmonstr-medium-1.png', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/img_3863.jpeg', 2:16:10 PM: to: '/images/img_3863.jpeg', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/instagram_icon.png.webp', 2:16:10 PM: to: '/images/instagram_icon.png.webp', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/linkedin_logo_initials.png', 2:16:10 PM: to: '/images/linkedin_logo_initials.png', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/medium-512.webp', 2:16:10 PM: to: '/images/medium-512.webp', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/medium.png', 2:16:10 PM: to: '/images/medium.png', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/new-instagram-logo-white-border-icon-png-large.png', 2:16:10 PM: to: '/images/new-instagram-logo-white-border-icon-png-large.png', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/new-linkedin-logo-white-black-png.png', 2:16:10 PM: to: '/images/new-linkedin-logo-white-black-png.png', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/p1100057.jpg', 2:16:10 PM: to: '/images/p1100057.jpg', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/p1100062.jpg', 2:16:10 PM: to: '/images/p1100062.jpg', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/page24_skatearticle.png', 2:16:10 PM: to: '/images/page24_skatearticle.png', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/r1-07874-0003.jpg', 2:16:10 PM: to: '/images/r1-07874-0003.jpg', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/realarticl4.png', 2:16:10 PM: to: '/images/realarticl4.png', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/screen-shot-2022-04-21-at-4.45.40-pm.png', 2:16:10 PM: to: '/images/screen-shot-2022-04-21-at-4.45.40-pm.png', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/seagull-copy.png', 2:16:10 PM: to: '/images/seagull-copy.png', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/seagull.jpg', 2:16:10 PM: to: '/images/seagull.jpg', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/untitled-design-1-1536x1071-1-.png', 2:16:10 PM: to: '/images/untitled-design-1-1536x1071-1-.png', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/untitled-design-1-1536x1071.png', 2:16:10 PM: to: '/images/untitled-design-1-1536x1071.png', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/untitled-design-1536x1071.png', 2:16:10 PM: to: '/images/untitled-design-1536x1071.png', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/uva-logo.png', 2:16:10 PM: to: '/images/uva-logo.png', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/valutavideo.jpeg', 2:16:10 PM: to: '/images/valutavideo.jpeg', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/windmill-leiden.jpeg', 2:16:10 PM: to: '/images/windmill-leiden.jpeg', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/images/yasman.png', 2:16:10 PM: to: '/images/yasman.png', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/styles/content.module.css', 2:16:10 PM: to: '/styles/content.module.css', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/styles/variables.css', 2:16:10 PM: to: '/styles/variables.css', 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: status: 200 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/*', 2:16:10 PM: to: '/.netlify/functions/___netlify-handler', 2:16:10 PM: status: 200, 2:16:10 PM: conditions: { Cookie: [Array] }, 2:16:10 PM: force: true 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/_next/data/102vwDfM1oq7ReG-VTo1T/articles.json', 2:16:10 PM: to: '/.netlify/builders/___netlify-odb-handler', 2:16:10 PM: status: 200, 2:16:10 PM: force: true 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/articles', 2:16:10 PM: to: '/.netlify/builders/___netlify-odb-handler', 2:16:10 PM: status: 200, 2:16:10 PM: force: true 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/_next/data/102vwDfM1oq7ReG-VTo1T/index.json', 2:16:10 PM: to: '/.netlify/builders/___netlify-odb-handler', 2:16:10 PM: status: 200, 2:16:10 PM: force: true 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/', 2:16:10 PM: to: '/.netlify/builders/___netlify-odb-handler', 2:16:10 PM: status: 200, 2:16:10 PM: force: true 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/_next/data/102vwDfM1oq7ReG-VTo1T/_offline.json', 2:16:10 PM: to: '/.netlify/functions/___netlify-handler', 2:16:10 PM: status: 200, 2:16:10 PM: force: false 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/_offline', 2:16:10 PM: to: '/.netlify/functions/___netlify-handler', 2:16:10 PM: status: 200, 2:16:10 PM: force: false 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/_next/data/102vwDfM1oq7ReG-VTo1T/blog/categories/:name.json', 2:16:10 PM: to: '/.netlify/builders/___netlify-odb-handler', 2:16:10 PM: status: 200, 2:16:10 PM: force: false 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/blog/categories/:name', 2:16:10 PM: to: '/.netlify/builders/___netlify-odb-handler', 2:16:10 PM: status: 200, 2:16:10 PM: force: false 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/_next/data/102vwDfM1oq7ReG-VTo1T/blog/:postId.json', 2:16:10 PM: to: '/server/pages/404.html', 2:16:10 PM: status: 404, 2:16:10 PM: force: false 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/blog/:postId', 2:16:10 PM: to: '/server/pages/404.html', 2:16:10 PM: status: 404, 2:16:10 PM: force: false 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/_next/data/102vwDfM1oq7ReG-VTo1T/portfolio/:experienceId.json', 2:16:10 PM: to: '/server/pages/404.html', 2:16:10 PM: status: 404, 2:16:10 PM: force: false 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/portfolio/:experienceId', 2:16:10 PM: to: '/server/pages/404.html', 2:16:10 PM: status: 404, 2:16:10 PM: force: false 2:16:10 PM: }, 2:16:10 PM: { 2:16:10 PM: from: '/*', 2:16:10 PM: to: '/.netlify/functions/___netlify-handler', 2:16:10 PM: status: 200 2:16:10 PM: } 2:16:10 PM: ]. 2:16:10 PM: ​ 2:16:10 PM: (@netlify/plugin-nextjs onBuild completed in 106ms) 2:16:10 PM: ​ 2:16:10 PM: 4. Functions bundling 2:16:10 PM: ──────────────────────────────────────────────────────────────── 2:16:10 PM: ​ 2:16:10 PM: Packaging Functions from .netlify/functions-internal directory: 2:16:10 PM: - ___netlify-handler/___netlify-handler.js 2:16:10 PM: - ___netlify-odb-handler/___netlify-odb-handler.js 2:16:10 PM: - _ipx/_ipx.js 2:16:10 PM: ​ 2:16:37 PM: ​ 2:16:37 PM: (Functions bundling completed in 27s) 2:16:37 PM: ​ 2:16:37 PM: 5. Edge Functions bundling 2:16:37 PM: ──────────────────────────────────────────────────────────────── 2:16:37 PM: ​ 2:16:38 PM: ​ 2:16:38 PM: (Edge Functions bundling completed in 308ms) 2:16:38 PM: ​ 2:16:38 PM: 6. @netlify/plugin-nextjs (onPostBuild event) 2:16:38 PM: ──────────────────────────────────────────────────────────────── 2:16:38 PM: ​ 2:16:38 PM: Next.js cache saved. 2:16:38 PM: ​ 2:16:38 PM: (@netlify/plugin-nextjs onPostBuild completed in 53ms) 2:16:38 PM: ​ 2:16:38 PM: 7. Deploy site 2:16:38 PM: ──────────────────────────────────────────────────────────────── 2:16:38 PM: ​ 2:16:38 PM: Starting to deploy site from '.next' 2:16:38 PM: Calculating files to upload 2:16:38 PM: 49 new files to upload 2:16:38 PM: 2 new functions to upload 2:16:46 PM: Section completed: deploying 2:16:46 PM: Site deploy was successfully initiated 2:16:46 PM: ​ 2:16:46 PM: (Deploy site completed in 7.9s) 2:16:46 PM: ​ 2:16:46 PM: Starting post processing 2:16:46 PM: Netlify Build Complete 2:16:46 PM: ──────────────────────────────────────────────────────────────── 2:16:46 PM: ​ 2:16:46 PM: (Netlify Build completed in 49.6s) 2:16:46 PM: Caching artifacts 2:16:46 PM: Started saving node modules 2:16:46 PM: Post processing - HTML 2:16:46 PM: Finished saving node modules 2:16:46 PM: Started saving build plugins 2:16:46 PM: Finished saving build plugins 2:16:46 PM: Started saving corepack cache 2:16:46 PM: Finished saving corepack cache 2:16:46 PM: Started saving yarn cache 2:16:47 PM: Processing form - contact 2:16:47 PM: Detected form fields: - name - email - message 2:16:47 PM: Finished saving yarn cache 2:16:47 PM: Started saving pip cache 2:16:47 PM: Finished saving pip cache 2:16:47 PM: Started saving emacs cask dependencies 2:16:47 PM: Finished saving emacs cask dependencies 2:16:47 PM: Started saving maven dependencies 2:16:47 PM: Finished saving maven dependencies 2:16:47 PM: Started saving boot dependencies 2:16:47 PM: Finished saving boot dependencies 2:16:47 PM: Started saving rust rustup cache 2:16:47 PM: Finished saving rust rustup cache 2:16:47 PM: Started saving go dependencies 2:16:48 PM: Finished saving go dependencies 2:16:48 PM: Build script success 2:16:48 PM: Section completed: building 2:16:49 PM: Post processing - header rules 2:16:49 PM: Post processing - redirect rules 2:16:50 PM: Post processing done 2:16:50 PM: Section completed: postprocessing 2:16:52 PM: Site is live ✨ 2:16:53 PM: Uploading Cache of size 875.2MB 2:16:59 PM: Section completed: cleanup 2:16:59 PM: Finished processing build request in 1m28.104s```

Function logs

Function logs ``` # Paste logs here ```

.next JSON files

generated .next JSON files ``` # Paste file contents here. Please check there isn't any private info in them # You can either build locally, or download the deploy from Netlify by clicking the arrow next to the deploy time. ```
orinokai commented 1 year ago

Hi @alianza, prior to version 4.23.0 of our Next.js Runtime there was a bug that caused non-prerendered paths on fallback: false dynamic routes to be rendered as if fallback: blocking was set. We fixed this issue, but it seems your previous production builds may have been relying on this bug. Can you please check that your getStaticPaths functions are generating the correct paths in the correct format? e.g. https://github.com/alianza/portfolio-lea/blob/main/pages/blog/%5BpostId%5D.jsx#L11 Thank you!

alianza commented 1 year ago

Thank you for the reply and instructions!

I'm quite sure the correct data is coming through in my getStaticPaths functions. E.g. the Categories on the blog. getCategories() returns { name: 'Fiction', color: '#ffc857', textColor: 'dark', count: 0 } per category, Then the returned paths are mapped to:

paths [
  { params: { name: 'Poetry' } },
  { params: { name: 'Photography' } },
  { params: { name: 'Reflections' } },
  { params: { name: 'Fiction' } }
]

Then in getStaticProps params is set correctly E.g. params: { name: 'Fiction' } which getPostsByCategory also correctly returns the category from.

Same for other dynamic pre-rendered routes like the blog. Returned postId's look correct. E.g.:

postIds [
  { postId: '2022-10-24_capturing-birds-in-the-wild' },
  { postId: '2023-01-05_a-collection-of-haikus' },
  { postId: '2023-01-05_mind-over-matter' }
]

In getStaticProps params has the following value: { postId: '2023-01-05_a-collection-of-haikus' } which is correct and as expected.

Otherwise this wouldn't run correctly locally either, but locally everything works as expected without any custom fallback values set.

Also in the Netlify build logs I can see it built the pages:

6:56:05 PM: ├   ├ /blog/2022-10-24_capturing-birds-in-the-wild
6:56:05 PM: ├   ├ /blog/2023-01-05_a-collection-of-haikus
6:56:05 PM: ├   └ /blog/2023-01-05_mind-over-matter
6:56:05 PM: ├ ● /blog/categories (305 ms)                                                                         885 B          89.5 kB
6:56:05 PM: ├ ● /blog/categories/[name] (342 ms)                                                                  4.49 kB        90.7 kB
6:56:05 PM: ├   ├ /blog/categories/Poetry
6:56:05 PM: ├   ├ /blog/categories/Photography
6:56:05 PM: ├   ├ /blog/categories/Reflections
6:56:05 PM: ├   └ /blog/categories/Fiction

Is there anything I should do differently to make sure my application behaves the same when deployed on Netlify as it does locally when it comes to these statically generated (dynamic) routes? Previously that was never the case and the local development experience reflected what would be expected when deployed on Netlify.

Also if I build locally and then serve the application using next start everything works as expected. Pre-rendered (dynamic) routes as well.

Moreover I tried running the project using Netlify CLI locally, this also worked as expected with all dynamic routes also working as expected. I'm unsure how to continue looking for what is going wrong when the site is deployed to Netlify.

Lastly I deployed the site to Vercel instead, which worked no problem and all pre-rendered (dynamic) routes worked perfectly too.

I would be very surprised if my application relies on a bug that would have had to be present for so long, affecting such a basic functionality for Next.js, such as pre-rendered (dynamic) routes when at the same time all other types of testing this functionality (Local dev, local build + serve, Netlify CLI & Vercel) do all behave as expected.

I hope this information helps! Kind regards, J.W.

orinokai commented 1 year ago

Thank you for reporting this with a great repro and thanks for your detailed reply! This is a bug in our Runtime due to a change in Next.js v13.3.0. We have a PR ready to go and are hoping to get it merged into the release next week. Will update here when we do.

alianza commented 1 year ago

Thank you for reporting this with a great repro and thanks for your detailed reply! This is a bug in our Runtime due to a change in Next.js v13.3.0. We have a PR ready to go and are hoping to get it merged into the release next week. Will update here when we do.

Great to hear. Thanks for the swift responses! Looking forward to the fix and to hear from it! Good day

alianza commented 1 year ago

Amazing! I redeployed my site without changes and all the (pre-rendered dynamic routes) work properly again! Thank you for the quick resolution!