Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create-react-app and url base path for the development server

during development, I'd like to use an already existing test server, this server uses apache, so I basically used mod_proxy to proxy it to a subdirectory of my server, let's say http://myserver/myreactapp/ Problem is, I didnt find a way to tell the development server that the js shouldnt be in

<script type="text/javascript" src="/static/js/bundle.js"></script></body>

but in

<script type="text/javascript" src="/myreactapp/static/js/bundle.js"></script></body>

or more logically, in a relative path. I found this option for the build, but not the development server. what is a good way of achieving that ?

like image 902
beauchette Avatar asked Nov 18 '25 09:11

beauchette


1 Answers

If you use nginx, you can use alias like this:

location /static/ {
  alias /myreactapp/static/;
}

If you use apache, the alias syntax is:

Alias "/static" "/myreactapp/static"
like image 171
oklas Avatar answered Nov 20 '25 22:11

oklas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!