简体   繁体   English

如何在开发服务器中为 react-scripts 启动调用定义基本 URL

[英]how to define base URL in the dev server for react-scripts start call

I have a primary php server.我有一个主要的 php 服务器。 I have to run the reactjs dev server created from yarn start within a directory /reactive within the php site (using nginx proxy_pass).我必须运行 reactjs 开发服务器,该服务器从yarn start在 php 站点内的目录/reactive中创建(使用 nginx proxy_pass)。

But I cannot set the root of the node server to be /reactive .但是我不能将节点服务器的根设置为/reactive It sets it to / and therefore just the html file loads and tries to load bundle from /static/js/bundle.js which will fail.它将它设置为/ ,因此仅加载 html 文件并尝试从/static/js/bundle.js加载捆绑包,这将失败。 If it were /reactive/static/js/bundle.js it would have worked.如果它是/reactive/static/js/bundle.js它会起作用的。 How to achieve this configuration?如何实现这个配置?

"react": "16.8.1"
"react-scripts": "2.1.5"

at yow package.json in the npm start script and a PUBLIC_URL variablenpm start脚本和 PUBLIC_URL 变量中

"homepage": "/yow-path",
"scripts":{
   "start": "PUBLIC_URL=/reactive node start.js"
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM