Changeset 931b4cb in Klonkt
- Timestamp:
- 06/28/2026 12:22:06 PM (2 months ago)
- Branches:
- main
- Children:
- cca2e89
- Parents:
- 0a58300
- File:
-
- 1 edited
-
src/server.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/server.js
r0a58300 r931b4cb 149 149 if (!isDev) app.set('trust proxy', 1); 150 150 151 // Collapse leading duplicate slashes in the path. A reverse proxy that proxies with 152 // `RewriteRule ^(.*)$ http://localhost:3000/$1` (Apache [P]) sends "//" for the root and 153 // "//path" for sub-paths (the captured $1 keeps its leading slash) → Express matches no 154 // route → the whole site 404'd behind such a proxy. Normalising here makes Klonkt resilient 155 // to that common reverse-proxy setup. (Only the leading slashes; the query string is intact.) 156 app.use((req, res, next) => { 157 if (req.url.startsWith('//')) req.url = req.url.replace(/^\/+/, '/'); 158 next(); 159 }); 160 151 161 // Create/migrate the schema BEFORE anything touches the DB: the session store 152 162 // queries the `sessions` table on construction, so on a fresh install the tables
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)