11. Deployment
In development, two servers work together: [Vite] (the client) and the JSON server (the API). In production, there is only one:

1. Build the client. In the [rdvmedecins-vuejs] folder:
The console displays (excerpt):
The [dist/] folder contains the entire application: a page named [index.html], a stylesheet, and optimized [JavaScript] files (the code from [Vue.js], the router, [Pinia]... and ours). The pages loaded on demand ([() => import(...)]) each have their own file. The name of each file contains a hash of its contents ([index-DX4x1EAt.js]): a new version will have a different name, and a browser will never be able to cache an outdated version.
You can verify this version using [npm run preview] (http://localhost:4173).
2. Upload it to the server. Copy the CONTENTS of the [dist/] folder to the [client/] folder at the root of the JSON server ([rdvmedecins-nestjs-json/client/index.html], [rdvmedecins-nestjs-json/client/assets/...]), then restart the server. It displays:
The complete application is then available at http://localhost:8080. The server serves the client’s files and returns [index.html] for any other address outside of [/api]: reloading the [/schedule] page works (it is the client’s router that displays it). For the curious reader, it is the file [src/web/client-spa.ts] on the server that performs this task.
3. In a live production environment, don’t forget the server file [.env]:
- a long, random [JWT_SECRET];
- an empty [CAPTCHA_TEST];
- [COOKIE_SECURE=true] if the site is served via HTTPS (it must be: passwords are being transmitted);
- [TRUST_PROXY=true] if the server is behind a proxy ([nginx]...), so that the attempt limit sees the clients’ actual IP address.
We then launch the compiled server: [npm run build], followed by [npm run start:prod].