簡體   English   中英

當我嘗試登陸除主頁以外的任何頁面時,下一個 js 應用程序顯示 404

[英]Next js application is showing 404 when I try to land any page except home

我已經在 firebase 上部署了我的下一個 js 應用程序。 當我嘗試直接登陸除主頁以外的任何頁面時,它向我顯示 404 頁面。

假設,我的應用程序鏈接是:example.com,它有頁面。

  • 關於
  • 接觸

當我嘗試訪問 example.com 時,它按預期顯示了主頁。 但是當我嘗試訪問 example.com/about 時,它會顯示 404 頁面。 但問題是,當我訪問 example.com/about 並手動重新加載頁面時,about 頁面會按預期顯示。

我試圖在 firebase 中部署。

這是我的腳本命令

"dev": "next dev",
        "build": "next build && next export",
        "start": "next start",

在您的firebase.json中啟用rewrites以將所有請求重定向到您的 index.html 文件。

"hosting": {
  // ...

  // Serves index.html for requests to files or directories that do not exist
  "rewrites": [ {
    "source": "**",
    "destination": "/index.html"
  } ]
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM