[英]App returns 404 when deployed to production server
My react app is working fine in local, but when I deploy it to a development server I cannot hit the refresh bar.我的反应应用程序在本地运行良好,但是当我将它部署到开发服务器时,我无法点击刷新栏。 If I do, it will immediately throw a 404 not found error.
如果我这样做了,它会立即抛出 404 not found 错误。 I cannot manually navigate using the address bar.
我无法使用地址栏手动导航。
I have tried modifying the .htaccess
file in the server.我尝试修改服务器中的
.htaccess
文件。 still no luck.仍然没有运气。 I tried tinkering with the router adding
browserhistory
and stuff and still no luck.我尝试修补路由器添加
browserhistory
历史记录和其他东西,但仍然没有运气。 I understand this has something to do with client side routing
.我知道这与
client side routing
有关。 This is the .htaccess
file I'm currently using这是我目前使用的
.htaccess
文件
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]
This is the generic code I'm using in App.js
这是我在
App.js
中使用的通用代码
import React from "react";
import { Switch, Route,Link } from "react-router-dom";
import Backup from "./forms/backup_request/backupRequest";
import Restoration from "./forms/restoration_request/RestorationRequest";
import AssetRequest from "./forms/new_asset_request/AssetRequest";
class App extends React.Component {
render() {
return (
<div>
<Switch>
<Route exact path="/" component={Home} />
<Route path="/backup_request" component={Backup} />
<Route path="/restoration_request" component={Restoration}/>
<Route path="/new_asset_request" component={AssetRequest} />
</div>
</Switch>
)
}
}
This is the error message displayed这是显示的错误消息
Not Found The requested URL /id_request was not found on this server.
fixed it.解决它。 it was a serverside error.
这是一个服务器端错误。 needed configuring on the apache server to accept the
.htaccess
file.需要在 apache 服务器上进行配置以接受
.htaccess
文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.