The Comunidades Vecinos frontend is a single-page application built with React 19 and Vite 8. It uses Bootstrap 5 for layout and components, Axios for HTTP requests,Documentation Index
Fetch the complete documentation index at: https://mintlify.com/GuillermoNavarro/Proyecto_comunidades/llms.txt
Use this file to discover all available pages before exploring further.
react-router-dom v7 for client-side routing, and jwt-decode to read JWT claims on the client. In development, Vite’s built-in proxy transparently forwards all /api requests to the Spring Boot backend so you never have to worry about CORS.
Requirements
- Node.js 18+
- npm (bundled with Node.js)
Installation and Development Server
Install dependencies
From the project root, navigate to the
frontend/ directory and install all npm packages:Start the development server
http://localhost:5173 with hot module replacement (HMR) enabled. Any change to a source file is reflected in the browser instantly without a full page reload.Make sure the backend is running
The frontend expects the Spring Boot API to be reachable at
http://localhost:8081. Start the backend first (see Backend Configuration), then open http://localhost:5173 in your browser.Vite Proxy Configuration
In development, Vite intercepts every request whose path starts with/api and forwards it to the backend at http://localhost:8081. This means the browser always talks to localhost:5173 — no CORS configuration is needed on the backend during development.
The proxy is configured in frontend/vite.config.js:
The
changeOrigin: true option rewrites the Host header of the proxied request to match the target, which is required for Spring Boot to accept the request. The secure: false option disables TLS certificate verification — safe for a local backend over plain HTTP.Authentication and Token Storage
After a successful login, the backend returns a signed JWT. The frontend stores this token inlocalStorage under the key token:
localStorage and attaches it as a Bearer token in the Authorization header. The jwt-decode library is used to extract claims such as idUsuario, idComunidad, and rol from the token payload on the client side — without making an additional network request.
Building for Production
frontend/dist/ directory. The output consists of static HTML, JavaScript, and CSS files that can be served by any web server.
The
base: './' option in vite.config.js ensures that all asset paths in the built output are relative, which makes the dist/ folder portable and deployable to any URL prefix.http://localhost:4173 serving the contents of dist/.
Nginx Production Reverse Proxy
In production, Nginx serves the staticdist/ files and forwards /api traffic to the Spring Boot backend. The following example configuration covers both responsibilities.
The
try_files $uri $uri/ /index.html directive is essential for React Router’s client-side routing to work correctly. Without it, navigating directly to a URL such as https://example.com/comunidad/dashboard would return a 404 from Nginx instead of loading the SPA and letting React Router handle the route.Key Dependencies
The following table lists the main runtime packages installed bynpm install. All versions are sourced directly from frontend/package.json.
| Package | Version | Purpose |
|---|---|---|
react | ^19.2.4 | Core UI library. |
react-dom | ^19.2.4 | React renderer for the browser DOM. |
react-router-dom | ^7.13.1 | Client-side routing for the SPA. |
axios | ^1.13.6 | HTTP client used for all API calls. |
bootstrap | ^5.3.2 | CSS framework imported globally in main.jsx. |
bootstrap-icons | ^1.13.1 | Icon font used throughout the UI. |
jwt-decode | ^4.0.0 | Decodes JWT payload claims on the client without verification. |