The Estructuras Backend API uses theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/nelrondon/backend-proyecto-estructuras/llms.txt
Use this file to discover all available pages before exploring further.
cors npm package to enforce a strict allowlist of origins that are permitted to make cross-origin HTTP requests. Because authentication relies on HTTP-only cookies, CORS must be configured with credentials: true so browsers include those cookies on cross-origin requests. Any origin not present in the allowlist receives an error and the request is rejected before it reaches any route handler.
Allowed Origins
The list of trusted origins is defined insrc/config.js alongside the other environment-level constants:
| Origin | Purpose |
|---|---|
http://localhost:5173 | Local Vite development server (default Vite port) |
https://proyecto-estructuras-topaz.vercel.app | Production frontend deployed on Vercel |
CORS Middleware Configuration
The CORS middleware is registered insrc/index.js as the very first middleware so that preflight OPTIONS requests and cross-origin rejections are handled before any application logic runs.
How the origin callback works
- No
Originheader (!origin) — The request is allowed unconditionally. This covers server-to-server calls,curlcommands, and Postman requests where no origin is sent. The callback resolves withcallback(null, true). - Origin in
ALLOWED_ORIGINS— The browser-sentOriginheader matches an entry in the list. The callback resolves withcallback(null, true)and the browser receives the appropriateAccess-Control-Allow-Originheader. - Origin not in
ALLOWED_ORIGINS— The callback resolves withcallback(new Error("Not allowed by CORS")). Thecorspackage converts this into a standard error response and the browser blocks the request.
credentials: true
Setting credentials: true instructs the cors package to include the Access-Control-Allow-Credentials: true response header. Without this header, browsers refuse to expose cross-origin responses to JavaScript code when the request was made with credentials: 'include' — which is exactly how the frontend must send requests so that the authentication cookie is attached.
x-powered-by disabled
X-Powered-By: Express header to every response by default. Disabling it removes a fingerprint that attackers could use to target known Express vulnerabilities. This is a minor but costless hardening step.
Adding a New Allowed Origin
To permit a new frontend URL — for example, a staging environment — opensrc/config.js and append the origin to the ALLOWED_ORIGINS array:
Origins must include the protocol (
https://) and must not include a trailing slash. https://ejemplo.com and https://ejemplo.com/ are treated as different strings by the includes check, so only the slash-free form will match the Origin header that browsers send.config.js. No other file needs to change — the origin callback reads from ALLOWED_ORIGINS at runtime, so a single array update propagates to the CORS check automatically.