跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • 请问下各位大佬,编译后部署怎么访问不了其他路由
未分類
19 5 月 2020

请问下各位大佬,编译后部署怎么访问不了其他路由

请问下各位大佬,编译后部署怎么访问不了其他路由

資深大佬 : autoname 1

http://localhost:3000/main
http://localhost:3000/login
http://localhost:3000/admin

调试模式下,本地都可以访问

编译后部署到虚拟机,就访问不了,

访问一直都是 login 默认路由页面。

其他页面

直接抛出 nginx 的 404 页面。

也不是我自定的 react 路由里面的 404 页面

`

import React from ‘react’
import {BrowserRouter as Router,Route,Switch} from “react-router-dom”
import App from ‘../App’

import Home from ‘../test/Login’
import Login from ‘../test/Login’
import Admin from ‘../test/Admin’
import Info from ‘../test/Info’
import NoMatch from ‘../tool/No404’
import Main from ‘../test/Main’
//import Cir from ‘../tool/Circling’

//https://blog.csdn.net/qq_42813491/article/details/92579240
export default class Routers extends React.Component{

componentDidMount() {
//console.log(‘ddd’);
}

render() {
return(
<Router>
<App>
<Switch>
<Route path=”/main” render={
()=>
<Main>
<Route path=”/main/:values” component={Info} />
</Main>
}>
</Route>

<Route exact path=”/” component={Home} />
<Route path=”/login” component={Login}/>
<Route path=”/admin” component={Admin} />
<Route component={NoMatch}></Route>
</Switch>
</App>

</Router>

);
}
}`

大佬有話說 (3)

  • 資深大佬 : otakustay

    因为你的 nginx 啥的没有配 try_files 规则吧
    https://segmentfault.com/a/1190000013218418

  • 資深大佬 : qinxi

    因为路由被 nginx 接管了

  • 主 資深大佬 : autoname

    这。。。还要配置 nginx 规则。。。
    谢谢大佬,

    try_files $uri $uri/ $uri/index.html /$1/ /$1/index.html;
    解决了

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具