[英]React: 404/No folder structure after running `npm run build`
I can access my index page perfectly with the following apache config我可以使用以下 apache 配置完美访问我的索引页面
<VirtualHost *:443>
ServerName MyReactAppSite
DocumentRoot /var/www/sites/MyReactAppSite/client/build/
</VirtualHost>
in my App.js folder I have the following code在我的 App.js 文件夹中,我有以下代码
<Route exact path="/home" component={Home} />
So after logging in app routes to http://MyReactAppSite/home所以登录应用程序后路由到http://MyReactAppSite/home
Works perfectly with >> npm run start
与 >>
npm run start
完美配合
404 not found >> npm run build
followed by serve -s build
404 未找到 >>
npm run build
后跟serve -s build
When I look inside the /build folder there is no /home folder so what is the proper way to get a production build of a React App.当我查看 /build 文件夹时,没有 /home 文件夹,那么获取 React 应用程序的生产版本的正确方法是什么。 I have read this whole page 2x https://create-react-app.dev/docs/deployment/ and can't seem to figure it out.
我已经阅读了整页 2x https://create-react-app.dev/docs/deployment/并且似乎无法弄清楚。
In order to facilitate the REST attributes of my particular app I had to set up a .htaccess file to rout all request back into the index.html file created by my React App build.为了方便我的特定应用程序的 REST 属性,我必须设置一个 .htaccess 文件来将所有请求路由回由我的 React App 构建创建的 index.html 文件。
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteCond %{REQUEST_URI} !=/upload
RewriteCond %{REQUEST_URI} !=/tmp
RewriteRule ^ index.html [L]
</IfModule>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.