Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
622 views
in Technique[技术] by (71.8m points)

nginx怎么配置react的静态地址的路径?

BrowserRouter模式的路由.一般地址带参数:
正常静态文件的地址:www.xxx.com/static/css/common.css

当访问www.xxx.com/game/22的时候 静态文件地址:www.xxx.com/game/static/css/common.css 导致报错了.
它把game这个路由名称也带进来了..
请问nginx配置 怎么处理静态文件的 地址规则?
image.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

以下是我的nginx代理方式:

项目访问地址: https://lurenhong.top/blog/#/home

如果想在根域名下直接访问项目 location / 配置/就行 root或者alias 指向项目目录

location /blog {
  root  html;
  index  index.html index.htm;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...