English 中文(简体)
改性动态航道在建或部署时没有工作
原标题:React dynamic route doesn t work in build or when deployed

我在接手 app具时,或当我把电灯放在电放器上时,会遇到麻烦,难以找到一条改道去工作。 我的道路是:

<Route path="/" element={userID ? <Home /> : <Login />} />
<Route path="/register" element={userID ? <Home /> : <Register />} />
<Route path="/forgotPassword" element= {userID ? <Home /> : <ForgotPassword /> } />
<Route path="/resetPassword/:id/:token" element={userID ? <Home /> : <ResetPassword /> } />

当我用<代码>npm开动,所有这些路线都行得起。 然而,当我以建造方式管理这些公路时,或者当有人在放任时,“翻版”路线不会奏效,所有其他路线仍然行不通。 但是,关于重塑Pasword,如“Cannot GET /resetPasword/123/456”这一页。 这条路由背后产生,然后用电子邮件发出,但我认为这不会改变。

I tried going into package.json and adding "homepage": "." or "./", even tried setting it to "http://localhost:3000" to see if it fixed build mode. It did not. What s the issue here?

此外,在我的服务器上,我有这一代码,但无法确定是否需要改动:app.use(/,明示.static(path.join(_dirname, ./client/build )>;

问题回答

我在谈到我的问题时,有一些错误。

首先,在我的服务机.js后端档案中,我不得不增加这一数据,以收集所有非固定要求,转而处理反应指数。 添加你自己的反应途径,建立指数.html档案:

app.get( /* , (req, res) => {
  res.sendFile(path.join(__dirname,  ../client/build/index.html ));
});

此外,在该指数.html档案中,我必须补充以下内容:

<base href="/" />

这两者共同确定了这一问题。





相关问题
VS 2008 : How to publish with out DLLs?

I have developed a web application in Visual Studio 2008 and want to publish it in to the production server. I see a publish option there.But its producing files with DLL. I dont want to publish only ...

Apache: Deploying a new site to the server

I have a site currently live on a domain. I would like to switch it to a new site, that is currently in a password protected sub directory on this server. I have a "Site Maintenance in Progress" page....

Appropriate strategy for tagging and hotfixing with git

I was wondering if the strategy I m using for tagging and hotfixing tags (which then I use for deploying rails applications) with git is appropriate. For tagging I just tag a commit of the master ...

Pylons deployment questions

I m a beginner with Pylons and I ve mostly developed on my localhost using the built-in web server. I think it s time to start deployment for my personal blog, I have a Debian Lenny server with ...

Do I want Publish or Release Build in VB.net?

I wrote a little (like 40 lines little) Winforms application with VB.net in Visual Studio 2010. Now I ve released the code as a Google Code project. It s easy for a developer to get the source but I d ...

Need advice on my PHP development solution

Here is how our current php development solution is set up: Each developer work on their local machine. Each developer commit their change to a common SVN server (intranet). A commit hook upload the ...

loading from JAR files during deployment vs development

when i am loading some data into my java program, i usually use FileInputStream. however i deploy the program as a jar file and webstart, so i have to use getRessource() or getRessourceAsStream() to ...

热门标签