Comments (15)
访问不到还是什么
你确定index.html文件是放在/dist下的吗
把文件放到服务器上,路由访问到 index.html就行
from react-luo.
index.html 和 dist 是同级,不在dist 下面
from react-luo.
能访问到index.html吗
from react-luo.
http://localhost:8082/dist/index.html 是可以访问到index.html 的
没有代理的工程 http://localhost:8888/home 可以访问到页面
代理的nginx http://localhost:8082/dist/home 页面错误 访问的资源是http://localhost:8082/dist/dist/app.d66600.js
from react-luo.
额,那是什么问题,无法加载JS和CSS吗?
把webpack.production.config.js中的输出配置改成这样:
`
output: {
path: path.resolve(__dirname, 'build/dist'),
publicPath: 'dist/',
filename: '[name].[hash:6].js',
chunkFilename: '[name].[hash:6].chunk.js',
},
`
from react-luo.
是的,无法加载js 和css, 现在的output 就是这样配置的
就是js css 资源 多带一层 dist
webpack 配置就是用的你写的那个
主要是想nginx 代理之后 加一层 dist 字段分隔,不直接在端口下走路由
是不是工程需要改呢?
from react-luo.
等我配个nginx试一下
from react-luo.
没有问题额,我是这么配的
`
server {
listen 80;
server_name gd.isluo.com;
location / {
proxy_pass http://127.0.0.1:8888;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
error_page 404 500 502 503 504 /50x.html
location = /50x.html {
root html;
}
}
`
我在服务器上试的,用了Tomcat,Nginx代理到Tomcat.
我对Nginx也不是很了解。如果不行,你问下身边的后台程序员,后台程序员一般都知道这个。
from react-luo.
我知道这样配,问题是这样配的话一个程序就占用了一个端口,,端口有限 主要是希望 80/项目a
80/项目b 多个项目功用一个端口
from react-luo.
现在你这个路径访问不到 http://localhost:8082/dist/dist/app.d66600.js
是不是要配个静态文件访问路径什么的
from react-luo.
那么多资源总不能一个一个写吧,,而且怎么保证不和别的项目的资源冲突呢,就是这个愁啊
from react-luo.
就在你这个server{ } 里面再加一个:
location ~*/dist/{
root /dist/
}
就写一个,能访问到http://localhost:8082/dist/dist就行了
我不知道这样写对不对,大致是这个意思
from react-luo.
还是不行 ,我试试其他办法吧,你们项目不用nginx代理的么,有类似思路么。。谢谢
如果不代理的话,本地工程所有路由也加一层呢
from react-luo.
用的,但都是后台在处理。
我等会儿去问下后台是怎么弄的
from react-luo.
额,如果项目部署在服务器二级目录呢?
from react-luo.
Related Issues (20)
- 这个报错怎么回事:Warning: Hash history cannot PUSH the same path; a new entry will not be added to the history stack HOT 6
- css 样式里面的本地图片路径怎么打包到build里面 HOT 1
- css打包后怎么class名称后都加了这个后缀_7Z3_vq74 而html div 没有加后缀 导致样式名称不对 HOT 1
- 这个脚手架上怎么设置请求代理? HOT 3
- 内存溢出 HOT 5
- 服务器记录路由跳转 HOT 1
- 无法引入第三方样式 HOT 2
- ajax请求如何记录 HOT 1
- 引用相对路径图片 报错 HOT 4
- 切换成url 模式 模式报错 HOT 5
- 支持ssr HOT 2
- 添加对scss的支持 HOT 3
- mac上无法跑成功,node版本为8.11.0,同版本node可以在windows上跑通 HOT 11
- 有很多路由的时候,有什么简便的写法么? HOT 3
- 不做公共代码抽取么? HOT 1
- webpack5 HOT 3
- webpack 的loader配置应该不支持 antd 吧 HOT 3
- 开发ts版本 HOT 1
- 整个storybook HOT 1
- help! HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-luo.