Reputation: 953
I have an reactjs application that I have deploy on my web server.
I build my app (So it's create a build
folder) and when I want to start it with ~/.npm-packages/bin/serve -s ./build -l tcp://0.0.0.0:8100
it work (with work dir set to react/
, build is here react/build
but we can see all source code on my page, that theory not possible in production mode.
If I set the work dir to react/build
it return a 404 error.
Inside build
folder
It doesn't return any other error unfortunately.
Update: I only stock build
folder and it work, but we can always see source code even its in production mode.
If I change to react/build
, react/build/static
or other, it display 404.
Upvotes: 1
Views: 2848
Reputation: 5198
If you are using npm's serve (the default for create-react-app, which I am assuming you are using), that second argument is the directory to serve:
$ serve --help
$ serve} [-l listen_uri [-l ...]] [directory]
By default, serve will listen on 0.0.0.0:5000 and serve the
current working directory on that address.
-s, --single Rewrite all not-found requests to `index.html`
But serve is meant for development serving. It works fine for production of a small static site, but consider another production-proven web server.
Your unminified source should not be kept on a production server, at all. You should deploy just the build files to production.
Upvotes: 3