Next.js+;在Netlify上响应提供404的站点

Next.js+;在Netlify上响应提供404的站点,next.js,netlify,Next.js,Netlify,我正在尝试使用Netlify部署一个站点。 这就是回购协议。是指向已部署站点的链接 以下是部署日志: 1:24:35 PM: Build ready to start 1:24:37 PM: build-image version: 09c2cdcdf242cf2f57c9ee0fcad9d298fad9ad41 1:24:37 PM: build-image tag: v3.5.0 1:24:37 PM: buildbot version: 5988d267666895e50a3b61cb80

我正在尝试使用Netlify部署一个站点。 这就是回购协议。是指向已部署站点的链接

以下是部署日志:

1:24:35 PM: Build ready to start
1:24:37 PM: build-image version: 09c2cdcdf242cf2f57c9ee0fcad9d298fad9ad41
1:24:37 PM: build-image tag: v3.5.0
1:24:37 PM: buildbot version: 5988d267666895e50a3b61cb809f46c82b965ece
1:24:37 PM: Fetching cached dependencies
1:24:38 PM: Starting to download cache of 125.7MB
1:24:38 PM: Finished downloading cache in 778.297261ms
1:24:38 PM: Starting to extract cache
1:24:42 PM: Finished extracting cache in 3.552834242s
1:24:42 PM: Finished fetching cache in 4.36144324s
1:24:42 PM: Starting to prepare the repo for build
1:24:42 PM: Preparing Git Reference refs/heads/master
1:24:46 PM: Starting build script
1:24:46 PM: Installing dependencies
1:24:46 PM: Python version set to 2.7
1:24:46 PM: Started restoring cached node version
1:24:49 PM: Finished restoring cached node version
1:24:50 PM: v12.18.0 is already installed.
1:24:50 PM: Now using node v12.18.0 (npm v6.14.4)
1:24:50 PM: Started restoring cached build plugins
1:24:50 PM: Finished restoring cached build plugins
1:24:50 PM: Attempting ruby version 2.7.1, read from environment
1:24:52 PM: Using ruby version 2.7.1
1:24:52 PM: Using PHP version 5.6
1:24:52 PM: Started restoring cached node modules
1:24:52 PM: Finished restoring cached node modules
1:24:52 PM: Installing NPM modules using NPM version 6.14.4
1:24:57 PM: npm WARN react-no-ssr@1.1.0 requires a peer of react@^0.14.0 || ^15.0.0 but none is installed. You must install peer dependencies yourself.
1:24:57 PM: npm WARN mojosa@2.8.0 No repository field.
1:24:57 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/fsevents):
1:24:57 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
1:24:57 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
1:24:57 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
1:24:57 PM: audited 727 packages in 3.98s
1:24:57 PM: 32 packages are looking for funding
1:24:57 PM:   run `npm fund` for details
1:24:57 PM: found 3 low severity vulnerabilities
1:24:57 PM:   run `npm audit fix` to fix them, or `npm audit` for details
1:24:57 PM: NPM modules installed
1:24:57 PM: Started restoring cached go cache
1:24:57 PM: Finished restoring cached go cache
1:24:58 PM: go version go1.14.4 linux/amd64
1:24:58 PM: go version go1.14.4 linux/amd64
1:24:58 PM: Installing missing commands
1:24:58 PM: Verify run directory
1:24:59 PM: ​
1:24:59 PM: ────────────────────────────────────────────────────────────────
1:24:59 PM:   Netlify Build                                                 
1:24:59 PM: ────────────────────────────────────────────────────────────────
1:24:59 PM: ​
1:24:59 PM: ❯ Version
1:24:59 PM:   @netlify/build 5.5.5
1:24:59 PM: ​
1:24:59 PM: ❯ Flags
1:24:59 PM:   deployId: 5fcb7c03613bfc000921ccfb
1:24:59 PM:   mode: buildbot
1:24:59 PM: ​
1:24:59 PM: ❯ Current directory
1:24:59 PM:   /opt/build/repo
1:24:59 PM: ​
1:24:59 PM: ❯ Config file
1:24:59 PM:   No config file was defined: using default values.
1:24:59 PM: ​
1:24:59 PM: ❯ Context
1:24:59 PM:   production
1:24:59 PM: ​
1:24:59 PM: ────────────────────────────────────────────────────────────────
1:24:59 PM:   1. Build command from Netlify app                             
1:24:59 PM: ────────────────────────────────────────────────────────────────
1:24:59 PM: ​
1:24:59 PM: $ npm run build
1:24:59 PM: > mojosa@2.8.0 build /opt/build/repo
1:24:59 PM: > next build
1:25:00 PM: info  - Creating an optimized production build...
1:25:50 PM: info  - Compiled successfully
1:25:50 PM: info  - Collecting page data...
1:25:51 PM: Warning: You have opted-out of Automatic Static Optimization due to `getInitialProps` in `pages/_app`. This does not opt-out pages with `getStaticProps`
1:25:51 PM: Read more: https://err.sh/next.js/opt-out-auto-static-optimization
1:25:51 PM: Warning: You have opted-out of Automatic Static Optimization due to `getInitialProps` in `pages/_app`. This does not opt-out pages with `getStaticProps`
1:25:51 PM: Read more: https://err.sh/next.js/opt-out-auto-static-optimization
1:25:51 PM: Page                                                           Size     First Load JS
1:25:51 PM: ┌ λ /                                                          155 B           103 kB
1:25:51 PM: ├   /_app                                                      0 B            75.2 kB
1:25:51 PM: ├ λ /404                                                       2.69 kB        77.9 kB
1:25:51 PM: ├ λ /about-one                                                 3.19 kB         106 kB
1:25:51 PM: ├ λ /about-two                                                 3.44 kB         107 kB
1:25:51 PM: ├ λ /agency                                                    9.76 kB         119 kB
1:25:51 PM: ├ λ /app                                                       6.4 kB          116 kB
1:25:51 PM: ├ λ /blog-details                                              2.3 kB          106 kB
1:25:51 PM: ├ λ /blog-one                                                  1.41 kB         105 kB
1:25:51 PM: ├ λ /blog-two                                                  1.82 kB         105 kB
1:25:51 PM: ├ λ /cart                                                      1.92 kB         105 kB
1:25:51 PM: ├ λ /checkout                                                  11.8 kB         115 kB
1:25:51 PM: ├ λ /coming-soon                                               1.77 kB          77 kB
1:25:51 PM: ├ λ /contact                                                   1.48 kB         105 kB
1:25:51 PM: ├ λ /digital-marketing                                         9.31 kB         119 kB
1:25:51 PM: ├ λ /faq                                                       4.78 kB         108 kB
1:25:51 PM: ├ λ /features                                                  2.09 kB         105 kB
1:25:51 PM: ├ λ /gallery                                                   1.78 kB         105 kB
1:25:51 PM: ├ λ /login                                                     1.17 kB         104 kB
1:25:51 PM: ├ λ /payment-processing                                        7.18 kB         110 kB
1:25:51 PM: ├ λ /portfolio-one                                             1.46 kB         105 kB
1:25:51 PM: ├ λ /portfolio-three                                           1.48 kB         105 kB
1:25:51 PM: ├ λ /portfolio-two                                             1.47 kB         105 kB
1:25:51 PM: ├ λ /pricing-one                                               1.22 kB         104 kB
1:25:51 PM: ├ λ /pricing-three                                             1.11 kB         104 kB
1:25:51 PM: ├ λ /pricing-two                                               1.11 kB         104 kB
1:25:51 PM: ├ λ /product-landing                                           6.48 kB         110 kB
1:25:51 PM: ├ λ /project-details                                           1.97 kB         105 kB
1:25:51 PM: ├ λ /saas                                                      8.38 kB         118 kB
1:25:51 PM: ├ λ /services                                                  2.35 kB         106 kB
1:25:51 PM: ├ λ /shop-details                                              3.08 kB         106 kB
1:25:51 PM: ├ λ /shop-one                                                  1.83 kB         105 kB
1:25:51 PM: ├ λ /shop-two                                                  2.27 kB         106 kB
1:25:51 PM: ├ λ /signup                                                    1.14 kB         104 kB
1:25:51 PM: ├ λ /software-landing                                          5.51 kB         115 kB
1:25:51 PM: ├ λ /team-one                                                  1.11 kB         104 kB
1:25:51 PM: ├ λ /team-two                                                  1.14 kB         104 kB
1:25:51 PM: └ λ /thankyou                                                  807 B           104 kB
1:25:51 PM: + First Load JS shared by all                                  75.2 kB
1:25:51 PM:   ├ chunks/6e82a459cbd936bb22ee277ca91cac38288c570d.e1f4e8.js  12.8 kB
1:25:51 PM:   ├ chunks/b8612b88f7d3fea52646b544ce4fbd88373b49ea.e69209.js  7.03 kB
1:25:51 PM:   ├ chunks/framework.9e938b.js                                 40.4 kB
1:25:51 PM:   ├ chunks/main.bce543.js                                      6.54 kB
1:25:51 PM:   ├ chunks/pages/_app.2e4503.js                                7.29 kB
1:25:51 PM:   ├ chunks/webpack.3b269c.js                                   1.18 kB
1:25:51 PM:   └ css/bcf4d7e39a2d48e5cb09.css                               60.9 kB
1:25:51 PM: λ  (Server)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
1:25:51 PM: ○  (Static)  automatically rendered as static HTML (uses no initial props)
1:25:51 PM: ●  (SSG)     automatically generated as static HTML + JSON (uses getStaticProps)
1:25:51 PM:    (ISR)     incremental static regeneration (uses revalidate in getStaticProps)
1:25:51 PM: ​
1:25:51 PM: (build.command completed in 52.2s)
1:25:51 PM: ​
1:25:51 PM: ────────────────────────────────────────────────────────────────
1:25:51 PM:   Netlify Build Complete                                        
1:25:51 PM: ────────────────────────────────────────────────────────────────
1:25:51 PM: ​
1:25:51 PM: (Netlify Build completed in 52.3s)
1:25:52 PM: Caching artifacts
1:25:52 PM: Started saving node modules
1:25:52 PM: Finished saving node modules
1:25:52 PM: Started saving build plugins
1:25:52 PM: Finished saving build plugins
1:25:52 PM: Started saving pip cache
1:25:52 PM: Finished saving pip cache
1:25:52 PM: Started saving emacs cask dependencies
1:25:52 PM: Finished saving emacs cask dependencies
1:25:52 PM: Started saving maven dependencies
1:25:52 PM: Finished saving maven dependencies
1:25:52 PM: Started saving boot dependencies
1:25:52 PM: Finished saving boot dependencies
1:25:52 PM: Started saving go dependencies
1:25:52 PM: Finished saving go dependencies
1:25:52 PM: Build script success
1:25:52 PM: Starting to deploy site from ''
1:25:52 PM: Creating deploy tree asynchronously
1:25:52 PM: Creating deploy upload records
1:25:54 PM: 241 new files to upload
1:25:54 PM: 0 new functions to upload
1:26:01 PM: Starting post processing
1:26:02 PM: Post processing - HTML
1:26:05 PM: Post processing - header rules
1:26:05 PM: Post processing - redirect rules
1:26:05 PM: Post processing done
1:26:05 PM: Site is live ✨
1:26:21 PM: Finished processing build request in 1m43.999541831s
以下是部署配置:

Base directory - Not set
Build command- npm run build
Publish directory - Not set
Deploy log visibility - Logs are public
Builds - Active
我没有设置
发布目录
,因为它被脚本覆盖为
/。下一步
,这是正确的文件夹


有人能发现我做错了什么,以及我必须修改什么才能修复它吗?

在公共目录中创建一个重定向文件,并在其中添加
/*/index.html 200
。这将解决404问题。

在公共目录中创建一个_重定向文件,并在其中添加
/*/index.html 200
。这将解决404问题。

在类似情况下,不通过Netifly,删除服务器中现有的
页面
文件夹会停止404重定向

然而,在网上,普拉布在他的回答中链接了一个解释:

如果没有显式重定向,Netlify机器人程序会假定您正在请求与/index.html分离的页面,并且由于该页面实际上不存在,因此会返回一个错误。要在Netlify部署的SPA中启用干净的URL,请将以下规则添加到重定向文件中

/* /index.html 200

在类似的情况下,不是通过Netifly,删除服务器中现有的
页面
文件夹会停止404重定向

然而,在网上,普拉布在他的回答中链接了一个解释:

如果没有显式重定向,Netlify机器人程序会假定您正在请求与/index.html分离的页面,并且由于该页面实际上不存在,因此会返回一个错误。要在Netlify部署的SPA中启用干净的URL,请将以下规则添加到重定向文件中

/* /index.html 200