- in folder
src/client/config
, create a new file calledconfig.json
- add following configuration in it
{
"backend_url": "http://localhost:3001", // full url to backend server, without trailing "/"
"contact_email": "[email protected]" // an email for contact page
}
- you can use
src/client/config/config.json.template
as your starting point
Assuming you are in folder src/client
run following command to deploy with docker
- build the docker image
docker build -t your-moon-client --build-arg="BACKEND_URL=http://localhost:3001" --build-arg="[email protected]" .
-
Note that you MUST supply parameter
--build-arg
so docker can build the application into distributable package with correct backend url- Replace the value of
BACKEND_URL
with the url of your backend - Replace the value of
CONTACT_EMAIL
with your contact email
- Replace the value of
-
then, run docker container with following command
docker run -it --rm --name your-moon-client -p 5173:5173 your-moon-client
- install all dependencies
npm install
- build the frontend app
npm run build
- install
serve
to serve the app
npm install serve
- serve the app
serve -l tcp://127.0.0.1:5173 dist
Note: deploying the frontend with
serve
would likely cause routing issue. (e.g. refreshing/upload
path will return a 404)you need to route paths who do not associate with any file to index.html, for example,
/upload
should be route to index.htmlReferences:
https://stackoverflow.com/a/66514889
https://router.vuejs.org/guide/essentials/history-mode.html#HTML5-Mode
https://router.vuejs.org/guide/essentials/history-mode.html#nginx
It is easier to do that with a proper web server, you can use the nginx.conf file under
client
directory serving with nginx. Please refer to vue.js documentation for more detail
- you can also deploy client for development
npm run dev
Frontend is running on http://localhost:5173 by default