"Page not found" after deploying Next.js from subfolder in Github repo

After deploying a next.js site to netlify, I only see Page not found.

Build log:

10:48:53 PM: Build ready to start
10:48:55 PM: build-image version: 3571f0130496395a23bffe9820bc78b4f73a6234
10:48:55 PM: build-image tag: v3.7.0
10:48:55 PM: buildbot version: b8a7cb2ab30309dc791e77b97759136f817b5561
10:48:55 PM: Fetching cached dependencies
10:48:55 PM: Starting to download cache of 129.7MB
10:48:56 PM: Finished downloading cache in 875.748178ms
10:48:56 PM: Starting to extract cache
10:49:01 PM: Finished extracting cache in 4.447141531s
10:49:01 PM: Finished fetching cache in 5.378388964s
10:49:01 PM: Starting to prepare the repo for build
10:49:01 PM: Preparing Git Reference refs/heads/master
10:49:02 PM: Parsing package.json dependencies
10:49:03 PM: Starting build script
10:49:03 PM: Installing dependencies
10:49:03 PM: Python version set to 2.7
10:49:04 PM: Started restoring cached node version
10:49:07 PM: Finished restoring cached node version
10:49:07 PM: v12.18.0 is already installed.
10:49:08 PM: Now using node v12.18.0 (npm v6.14.4)
10:49:08 PM: Started restoring cached build plugins
10:49:08 PM: Finished restoring cached build plugins
10:49:08 PM: Attempting ruby version 2.7.1, read from environment
10:49:10 PM: Using ruby version 2.7.1
10:49:10 PM: Using PHP version 5.6
10:49:10 PM: Started restoring cached yarn cache
10:49:10 PM: Finished restoring cached yarn cache
10:49:10 PM: Started restoring cached node modules
10:49:10 PM: Finished restoring cached node modules
10:49:11 PM: Installing NPM modules using Yarn version 1.22.4
10:49:11 PM: yarn install v1.22.4
10:49:11 PM: warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
10:49:11 PM: [1/4] Resolving packages...
10:49:12 PM: [2/4] Fetching packages...
10:49:25 PM: info fsevents@2.3.2: The platform "linux" is incompatible with this module.
10:49:26 PM: info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
10:49:26 PM: [3/4] Linking dependencies...
10:49:26 PM: warning " > @chakra-ui/icons@1.0.7" has unmet peer dependency "@chakra-ui/system@>=1.0.0".
10:49:26 PM: warning "@chakra-ui/icons > @chakra-ui/icon@1.1.3" has unmet peer dependency "@chakra-ui/system@>=1.0.0".
10:49:26 PM: warning "@emotion/styled > @emotion/babel-plugin@11.1.2" has unmet peer dependency "@babel/core@^7.0.0".
10:49:26 PM: warning "@emotion/styled > @emotion/babel-plugin > @babel/plugin-syntax-jsx@7.12.1" has unmet peer dependency "@babel/core@^7.0.0-0".
10:49:26 PM: warning " > @typescript-eslint/eslint-plugin@4.18.0" has unmet peer dependency "eslint@^5.0.0 || ^6.0.0 || ^7.0.0".
10:49:26 PM: warning "@typescript-eslint/eslint-plugin > @typescript-eslint/experimental-utils@4.18.0" has unmet peer dependency "eslint@*".
10:49:26 PM: warning " > @typescript-eslint/parser@4.18.0" has unmet peer dependency "eslint@^5.0.0 || ^6.0.0 || ^7.0.0".
10:49:26 PM: warning " > eslint-plugin-simple-import-sort@7.0.0" has unmet peer dependency "eslint@>=5.0.0".
10:49:31 PM: [4/4] Building fresh packages...
10:49:31 PM: success Saved lockfile.
10:49:31 PM: Done in 20.17s.
10:49:32 PM: NPM modules installed using Yarn
10:49:32 PM: Started restoring cached go cache
10:49:32 PM: Finished restoring cached go cache
10:49:32 PM: go version go1.14.4 linux/amd64
10:49:32 PM: go version go1.14.4 linux/amd64
10:49:32 PM: Installing missing commands
10:49:32 PM: Verify run directory
10:49:34 PM: ​
10:49:34 PM: ────────────────────────────────────────────────────────────────
10:49:34 PM:   Netlify Build                                                 
10:49:34 PM: ────────────────────────────────────────────────────────────────
10:49:34 PM: ​
10:49:34 PM: ❯ Version
10:49:34 PM:   @netlify/build 9.11.4
10:49:34 PM: ​
10:49:34 PM: ❯ Flags
10:49:34 PM:   apiHost: api.netlify.com
10:49:34 PM:   cacheDir: /opt/build/cache
10:49:34 PM:   deployId: 605910c590aa921f12cc1f20
10:49:34 PM:   mode: buildbot
10:49:34 PM:   testOpts:
10:49:34 PM:     silentLingeringProcesses: ''
10:49:34 PM: ​
10:49:34 PM: ❯ Current directory
10:49:34 PM:   /opt/build/repo/src/Eventuras.WebClient
10:49:34 PM: ​
10:49:34 PM: ❯ Config file
10:49:34 PM:   No config file was defined: using default values.
10:49:34 PM: ​
10:49:34 PM: ❯ Context
10:49:34 PM:   production
10:49:34 PM: ​
10:49:34 PM: ❯ Installing plugins
10:49:34 PM:    - @netlify/plugin-nextjs@3.0.3
10:49:57 PM: ​
10:49:57 PM: ❯ Loading plugins
10:49:57 PM:    - @netlify/plugin-nextjs@3.0.3 from Netlify app
10:49:58 PM: ​
10:49:58 PM: ────────────────────────────────────────────────────────────────
10:49:58 PM:   1. onPreBuild command from @netlify/plugin-nextjs             
10:49:58 PM: ────────────────────────────────────────────────────────────────
10:49:58 PM: ​
10:49:58 PM: Static HTML export Next.js projects do not require this plugin. Check your project's build command for 'next export'.
​
10:49:58 PM: (@netlify/plugin-nextjs onPreBuild completed in 15ms)
10:49:58 PM: ​
10:49:58 PM: ────────────────────────────────────────────────────────────────
10:49:58 PM:   2. Build command from Netlify app                             
10:49:58 PM: ────────────────────────────────────────────────────────────────
10:49:58 PM: ​
10:49:58 PM: $ next build
10:49:59 PM: warn  - No build cache found. Please configure build caching for faster rebuilds. Read more: https://err.sh/next.js/no-cache
10:49:59 PM: info  - Creating an optimized production build...
10:50:55 PM: info  - Compiled successfully
10:50:55 PM: info  - Collecting page data...
10:51:00 PM: info  - Generating static pages (0/9)
10:51:04 PM: info  - Generating static pages (2/9)
10:51:04 PM: info  - Generating static pages (4/9)
10:51:04 PM: info  - Generating static pages (6/9)
10:51:05 PM: info  - Generating static pages (9/9)
10:51:05 PM: info  - Finalizing page optimization...
10:51:05 PM: Page                                                           Size     First Load JS
10:51:05 PM: β”Œ ● / (ISR: 1 Seconds)                                         3.62 kB         165 kB
10:51:05 PM: β”œ   /_app                                                      0 B             106 kB
10:51:05 PM: β”œ β—‹ /404                                                       3.03 kB         109 kB
10:51:05 PM: β”œ β—‹ /admin                                                     1.19 kB         162 kB
10:51:05 PM: β”œ β—‹ /admin/event/[id]                                          18.8 kB         180 kB
10:51:05 PM: β”œ Ξ» /api/auth/[...nextauth]                                    0 B             106 kB
10:51:05 PM: β”œ Ξ» /api/getEventurasData                                      0 B             106 kB
10:51:05 PM: β”œ ● /event/[id]                                                816 B           162 kB
10:51:05 PM: β”œ   β”œ /event/2
10:51:05 PM: β”œ   β”” /event/4
10:51:05 PM: β”œ β—‹ /user                                                      785 B           162 kB
10:51:05 PM: β”” β—‹ /user/profile                                              997 B           162 kB
10:51:05 PM: + First Load JS shared by all                                  106 kB
10:51:05 PM:   β”œ chunks/commons.73473c.js                                   13.6 kB
10:51:05 PM:   β”œ chunks/f8d5c98248609c76133cea53b3963eea796df3f2.57071e.js  24.7 kB
10:51:05 PM:   β”œ chunks/framework.e25a57.js                                 42.3 kB
10:51:05 PM:   β”œ chunks/main.dd4dca.js                                      6.59 kB
10:51:05 PM:   β”œ chunks/pages/_app.2352b9.js                                17.8 kB
10:51:05 PM:   β”” chunks/webpack.d39272.js                                   1.22 kB
10:51:05 PM: Ξ»  (Server)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
10:51:05 PM: β—‹  (Static)  automatically rendered as static HTML (uses no initial props)
10:51:05 PM: ●  (SSG)     automatically generated as static HTML + JSON (uses getStaticProps)
10:51:05 PM:    (ISR)     incremental static regeneration (uses revalidate in getStaticProps)
10:51:06 PM: ​
10:51:06 PM: (build.command completed in 1m 8s)
10:51:06 PM: ​
10:51:06 PM: ────────────────────────────────────────────────────────────────
10:51:06 PM:   3. onBuild command from @netlify/plugin-nextjs                
10:51:06 PM: ────────────────────────────────────────────────────────────────
10:51:06 PM: ​
10:51:06 PM: Static HTML export Next.js projects do not require this plugin. Check your project's build command for 'next export'.
​
10:51:06 PM: (@netlify/plugin-nextjs onBuild completed in 5ms)
10:51:06 PM: ​
10:51:06 PM: ────────────────────────────────────────────────────────────────
10:51:06 PM:   4. Deploy site                                                
10:51:06 PM: ────────────────────────────────────────────────────────────────
10:51:06 PM: ​
10:51:06 PM: Starting to deploy site from ''
10:51:07 PM: Creating deploy tree asynchronously
10:51:07 PM: Creating deploy upload records
10:51:15 PM: Starting post processing
10:51:15 PM: Post processing - HTML
10:51:15 PM: Post processing - header rules
10:51:15 PM: Post processing - redirect rules
10:51:15 PM: Post processing done
10:51:15 PM: 0 new files to upload
10:51:15 PM: 0 new functions to upload
10:51:15 PM: Site is live ✨
10:51:15 PM: Site deploy was successfully initiated
10:51:15 PM: ​
10:51:15 PM: (Deploy site completed in 9.8s)
10:51:16 PM: ​
10:51:16 PM: ────────────────────────────────────────────────────────────────
10:51:16 PM:   Netlify Build Complete                                        
10:51:16 PM: ────────────────────────────────────────────────────────────────
10:51:16 PM: ​
10:51:16 PM: (Netlify Build completed in 1m 41.8s)
10:51:16 PM: Caching artifacts
10:51:16 PM: Started saving node modules
10:51:16 PM: Finished saving node modules
10:51:16 PM: Started saving build plugins
10:51:16 PM: Finished saving build plugins
10:51:16 PM: Started saving yarn cache
10:51:16 PM: Finished saving yarn cache
10:51:16 PM: Started saving pip cache
10:51:16 PM: Finished saving pip cache
10:51:16 PM: Started saving emacs cask dependencies
10:51:16 PM: Finished saving emacs cask dependencies
10:51:16 PM: Started saving maven dependencies
10:51:16 PM: Finished saving maven dependencies
10:51:16 PM: Started saving boot dependencies
10:51:16 PM: Finished saving boot dependencies
10:51:16 PM: Started saving rust rustup cache
10:51:16 PM: Finished saving rust rustup cache
10:51:16 PM: Started saving go dependencies
10:51:16 PM: Finished saving go dependencies
10:51:16 PM: Build script success
10:51:44 PM: Finished processing build request in 2m49.239488437s

Shouldn’t the publish directory be out?

Thanks for your suggestion. I initially tried to follow this tutorial.

When setting publish directory to out, I get this log:

    8:48:23 AM: Build ready to start
8:48:25 AM: build-image version: 3571f0130496395a23bffe9820bc78b4f73a6234
8:48:25 AM: build-image tag: v3.7.0
8:48:25 AM: buildbot version: b8a7cb2ab30309dc791e77b97759136f817b5561
8:48:25 AM: Fetching cached dependencies
8:48:25 AM: Starting to download cache of 156.1MB
8:48:29 AM: Finished downloading cache in 3.769731808s
8:48:29 AM: Starting to extract cache
8:48:36 AM: Finished extracting cache in 7.368032204s
8:48:36 AM: Finished fetching cache in 11.211454883s
8:48:36 AM: Starting to prepare the repo for build
8:48:37 AM: Preparing Git Reference refs/heads/master
8:48:37 AM: Parsing package.json dependencies
8:48:39 AM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'src/Eventuras.WebClient/out' versus 'out' in the Netlify UI
8:48:39 AM: Starting build script
8:48:39 AM: Installing dependencies
8:48:39 AM: Python version set to 2.7
8:48:40 AM: Started restoring cached node version
8:48:43 AM: Finished restoring cached node version
8:48:44 AM: v12.18.0 is already installed.
8:48:45 AM: Now using node v12.18.0 (npm v6.14.4)
8:48:45 AM: Started restoring cached build plugins
8:48:45 AM: Finished restoring cached build plugins
8:48:45 AM: Attempting ruby version 2.7.1, read from environment
8:48:47 AM: Using ruby version 2.7.1
8:48:48 AM: Using PHP version 5.6
8:48:48 AM: Started restoring cached yarn cache
8:48:48 AM: Finished restoring cached yarn cache
8:48:48 AM: Started restoring cached node modules
8:48:48 AM: Finished restoring cached node modules
8:48:48 AM: Installing NPM modules using Yarn version 1.22.4
8:48:49 AM: yarn install v1.22.4
8:48:49 AM: warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
8:48:49 AM: [1/4] Resolving packages...
8:48:50 AM: [2/4] Fetching packages...
8:49:06 AM: info fsevents@2.3.2: The platform "linux" is incompatible with this module.
8:49:06 AM: info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
8:49:06 AM: [3/4] Linking dependencies...
8:49:06 AM: warning " > @chakra-ui/icons@1.0.7" has unmet peer dependency "@chakra-ui/system@>=1.0.0".
8:49:06 AM: warning "@chakra-ui/icons > @chakra-ui/icon@1.1.3" has unmet peer dependency "@chakra-ui/system@>=1.0.0".
8:49:06 AM: warning "@emotion/styled > @emotion/babel-plugin@11.1.2" has unmet peer dependency "@babel/core@^7.0.0".
8:49:06 AM: warning "@emotion/styled > @emotion/babel-plugin > @babel/plugin-syntax-jsx@7.12.1" has unmet peer dependency "@babel/core@^7.0.0-0".
8:49:06 AM: warning " > @typescript-eslint/eslint-plugin@4.18.0" has unmet peer dependency "eslint@^5.0.0 || ^6.0.0 || ^7.0.0".
8:49:06 AM: warning "@typescript-eslint/eslint-plugin > @typescript-eslint/experimental-utils@4.18.0" has unmet peer dependency "eslint@*".
8:49:06 AM: warning " > @typescript-eslint/parser@4.18.0" has unmet peer dependency "eslint@^5.0.0 || ^6.0.0 || ^7.0.0".
8:49:06 AM: warning " > eslint-plugin-simple-import-sort@7.0.0" has unmet peer dependency "eslint@>=5.0.0".
8:49:13 AM: [4/4] Building fresh packages...
8:49:13 AM: success Saved lockfile.
8:49:13 AM: Done in 23.78s.
8:49:13 AM: NPM modules installed using Yarn
8:49:13 AM: Started restoring cached go cache
8:49:13 AM: Finished restoring cached go cache
8:49:13 AM: go version go1.14.4 linux/amd64
8:49:13 AM: go version go1.14.4 linux/amd64
8:49:13 AM: Installing missing commands
8:49:13 AM: Verify run directory
8:49:16 AM: ​
8:49:16 AM: ────────────────────────────────────────────────────────────────
8:49:16 AM:   Netlify Build                                                 
8:49:16 AM: ────────────────────────────────────────────────────────────────
8:49:16 AM: ​
8:49:16 AM: ❯ Version
8:49:16 AM:   @netlify/build 9.11.4
8:49:16 AM: ​
8:49:16 AM: ❯ Flags
8:49:16 AM:   apiHost: api.netlify.com
8:49:16 AM:   cacheDir: /opt/build/cache
8:49:16 AM:   deployId: 60599d47c3acceb2cc13f2a3
8:49:16 AM:   mode: buildbot
8:49:16 AM:   testOpts:
8:49:16 AM:     silentLingeringProcesses: ''
8:49:16 AM: ​
8:49:16 AM: ❯ Current directory
8:49:16 AM:   /opt/build/repo/src/Eventuras.WebClient
8:49:16 AM: ​
8:49:16 AM: ❯ Config file
8:49:16 AM:   No config file was defined: using default values.
8:49:16 AM: ​
8:49:16 AM: ❯ Context
8:49:16 AM:   production
8:49:16 AM: ​
8:49:16 AM: ❯ Loading plugins
8:49:16 AM:    - @netlify/plugin-nextjs@3.0.3 from Netlify app
8:49:17 AM: ​
8:49:17 AM: ────────────────────────────────────────────────────────────────
8:49:17 AM:   1. onPreBuild command from @netlify/plugin-nextjs             
8:49:17 AM: ────────────────────────────────────────────────────────────────
8:49:17 AM: ​
8:49:17 AM: Static HTML export Next.js projects do not require this plugin. Check your project's build command for 'next export'.​
8:49:17 AM: (@netlify/plugin-nextjs onPreBuild completed in 13ms)
8:49:17 AM: ​
8:49:17 AM: ────────────────────────────────────────────────────────────────
8:49:17 AM:   2. Build command from Netlify app                             
8:49:17 AM: ────────────────────────────────────────────────────────────────
8:49:17 AM: ​
8:49:17 AM: $ next build
8:49:19 AM: warn  - No build cache found. Please configure build caching for faster rebuilds. Read more: https://err.sh/next.js/no-cache
8:49:19 AM: info  - Creating an optimized production build...
8:50:23 AM: info  - Compiled successfully
8:50:23 AM: info  - Collecting page data...
8:50:28 AM: info  - Generating static pages (0/9)
8:50:32 AM: info  - Generating static pages (2/9)
8:50:32 AM: info  - Generating static pages (4/9)
8:50:32 AM: info  - Generating static pages (6/9)
8:50:34 AM: info  - Generating static pages (9/9)
8:50:34 AM: info  - Finalizing page optimization...
8:50:34 AM: Page                                                           Size     First Load JS
8:50:34 AM: β”Œ ● / (ISR: 1 Seconds)                                         3.62 kB         165 kB
8:50:34 AM: β”œ   /_app                                                      0 B             106 kB
8:50:34 AM: β”œ β—‹ /404                                                       3.03 kB         109 kB
8:50:34 AM: β”œ β—‹ /admin                                                     1.19 kB         162 kB
8:50:34 AM: β”œ β—‹ /admin/event/[id]                                          18.8 kB         180 kB
8:50:34 AM: β”œ Ξ» /api/auth/[...nextauth]                                    0 B             106 kB
8:50:34 AM: β”œ Ξ» /api/getEventurasData                                      0 B             106 kB
8:50:34 AM: β”œ ● /event/[id]                                                816 B           162 kB
8:50:34 AM: β”œ   β”œ /event/2
8:50:34 AM: β”œ   β”” /event/4
8:50:34 AM: β”œ β—‹ /user                                                      785 B           162 kB
8:50:34 AM: β”” β—‹ /user/profile                                              997 B           162 kB
8:50:34 AM: + First Load JS shared by all                                  106 kB
8:50:34 AM:   β”œ chunks/commons.73473c.js                                   13.6 kB
8:50:34 AM:   β”œ chunks/f8d5c98248609c76133cea53b3963eea796df3f2.57071e.js  24.7 kB
8:50:34 AM:   β”œ chunks/framework.e25a57.js                                 42.3 kB
8:50:34 AM:   β”œ chunks/main.dd4dca.js                                      6.59 kB
8:50:34 AM:   β”œ chunks/pages/_app.2352b9.js                                17.8 kB
8:50:34 AM:   β”” chunks/webpack.d39272.js                                   1.22 kB
8:50:34 AM: Ξ»  (Server)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
8:50:34 AM: β—‹  (Static)  automatically rendered as static HTML (uses no initial props)
8:50:34 AM: ●  (SSG)     automatically generated as static HTML + JSON (uses getStaticProps)
8:50:34 AM:    (ISR)     incremental static regeneration (uses revalidate in getStaticProps)
8:50:34 AM: ​
8:50:34 AM: (build.command completed in 1m 17.4s)
8:50:34 AM: ​
8:50:34 AM: ────────────────────────────────────────────────────────────────
8:50:34 AM:   3. onBuild command from @netlify/plugin-nextjs                
8:50:34 AM: ────────────────────────────────────────────────────────────────
8:50:34 AM: ​
8:50:34 AM: Static HTML export Next.js projects do not require this plugin. Check your project's build command for 'next export'.​
8:50:34 AM: (@netlify/plugin-nextjs onBuild completed in 7ms)
8:50:34 AM: ​
8:50:34 AM: ────────────────────────────────────────────────────────────────
8:50:34 AM:   4. Deploy site                                                
8:50:34 AM: ────────────────────────────────────────────────────────────────
8:50:34 AM: ​
8:50:34 AM: ​
8:50:34 AM: ────────────────────────────────────────────────────────────────
8:50:34 AM:   Configuration error                                           
8:50:34 AM: ────────────────────────────────────────────────────────────────
8:50:34 AM: ​
8:50:34 AM:   Error message
8:50:34 AM:   Deploy did not succeed: Deploy directory 'src/Eventuras.WebClient/out' does not exist
8:50:34 AM: ​
8:50:34 AM:   Resolved config
8:50:34 AM:   build:
8:50:34 AM:     base: /opt/build/repo/src/Eventuras.WebClient
8:50:34 AM:     command: next build
8:50:34 AM:     commandOrigin: ui
8:50:34 AM:     environment:
8:50:34 AM:       - AUTH0_API_AUDIENCE
8:50:34 AM:       - AUTH0_CLIENT_ID
8:50:34 AM:       - AUTH0_CLIENT_SECRET
8:50:34 AM:       - AUTH0_DOMAIN
8:50:34 AM:       - NEXTAUTH_SECRET
8:50:34 AM:       - NEXTAUTH_URL
8:50:34 AM:       - NEXT_PUBLIC_API_BASE_URL
8:50:34 AM:       - NEXT_PUBLIC_APPLICATION_URL
8:50:34 AM:     publish: /opt/build/repo/src/Eventuras.WebClient/out
8:50:34 AM:   plugins:
8:50:34 AM:     - inputs: {}
8:50:34 AM:       origin: ui
8:50:34 AM:       package: '@netlify/plugin-nextjs'
8:50:34 AM: Caching artifacts
8:50:34 AM: Started saving node modules
8:50:34 AM: Finished saving node modules
8:50:34 AM: Started saving build plugins
8:50:34 AM: Finished saving build plugins
8:50:34 AM: Started saving yarn cache
8:50:34 AM: Finished saving yarn cache
8:50:34 AM: Started saving pip cache
8:50:34 AM: Finished saving pip cache
8:50:34 AM: Started saving emacs cask dependencies
8:50:34 AM: Finished saving emacs cask dependencies
8:50:34 AM: Started saving maven dependencies
8:50:34 AM: Finished saving maven dependencies
8:50:34 AM: Started saving boot dependencies
8:50:35 AM: Finished saving boot dependencies
8:50:35 AM: Started saving rust rustup cache
8:50:35 AM: Finished saving rust rustup cache
8:50:35 AM: Started saving go dependencies
8:50:35 AM: Finished saving go dependencies
8:50:35 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
8:50:35 AM: Failing build: Failed to build site
8:50:35 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2
8:50:36 AM: Finished processing build request in 2m10.947537898s

I should have mentioned this before, your export script needs to be npm run build as NextJS doesn’t build the static HTML by just the build command. So, your package.json already has the correct command set (next build && next generate).

I think Netlify recently introduced a plugin related to this, however since I don’t use NextJS, I’ve not tried or don’t know what exactly it does. But yeah, before the plugin was there, NextJS websites would work on Nelify using next build && next export as the command and out as the publish path.

Thanks again for your suggestion. I have tried to use the Essential Next js plugin. I need some server functions, in the pages/api folder. Therefor next export is not so suitable.

Well, Netlify needs only static assets to serve, it can’t serve anything else. So, if your NextJS output is not generating any static files, it might not work with Netlify. However, if it does generate, you could try running a build locally and see what your publish path is. It would be the folder with the index.html inside it.

Thanks! I was looking into the docs, and seems like it should be possible to also run sites with api functions. I was reading this page: Next.js on Netlify | Netlify Docs

However if not possible, I will look into another solution.

I solved it! In case any other have trouble deploying applications from a subfolder of the source repo, all seems to work good if adding a period to the publish directory like this:

There also was an error in my build scripts command in package.json. I had npx build && npx export, however for api functions it works best with only npx build.

Now all my api functions runs well!

Hi @losviko !

Thanks so much for sharing your solution as well as this screenshot with the Forums! This benefits future Forums users who may encounter something similar, so we really appreciate it :netliconfetti:

1 Like