Redirect other domains to campercan.net #13

Merged
Claude merged 2 commits from cc-8-domain into site-hardening 2026-10-07 14:17:06 +00:00
Collaborator

Makes https://campercan.net the canonical origin. Requests whose Host is in redirectHosts (campercan.io, www.campercan.io, www.campercan.net) get a 301 to the same path and query on the canonical origin, before the method check. Any other host, including localhost and NPM's internal name, is served as before, so nothing loops.

NPM must forward the original Host header (default). Both settings live in src/site.json.

Tested with node build.js and node --test (16 pass). The new redirect test fails without the server change.

Ticket: CC-8.

Makes https://campercan.net the canonical origin. Requests whose Host is in `redirectHosts` (campercan.io, www.campercan.io, www.campercan.net) get a 301 to the same path and query on the canonical origin, before the method check. Any other host, including localhost and NPM's internal name, is served as before, so nothing loops. NPM must forward the original Host header (default). Both settings live in `src/site.json`. Tested with `node build.js` and `node --test` (16 pass). The new redirect test fails without the server change. Ticket: CC-8.
Redirect other domains to campercan.net
All checks were successful
CI / check (pull_request) Successful in 9s
e8820d9e71
Claude left a comment

Two minor points, no blockers.

Two minor points, no blockers.
server.js Outdated
@ -76,6 +77,10 @@ function register(req, res) {
}
http.createServer((req, res) => {
if (redirectHosts.includes((req.headers.host || '').replace(/:\d+$/, ''))) {
Author
Collaborator

Host match is case-sensitive, so Campercan.IO is served instead of redirected. Lower-case the header before the lookup: .toLowerCase().

Host match is case-sensitive, so `Campercan.IO` is served instead of redirected. Lower-case the header before the lookup: `.toLowerCase()`.
@ -60,6 +60,13 @@ test('serves clean URLs, caching, CSP and refuses traversal', async () => {
}
});
test('other domains 301 to the canonical origin, other hosts are served', async () => {
Author
Collaborator

Test only covers campercan.io with no port. Add a case with a port and a www. host (e.g. www.campercan.net:8080) so the port strip and the list entries are exercised.

Test only covers `campercan.io` with no port. Add a case with a port and a `www.` host (e.g. `www.campercan.net:8080`) so the port strip and the list entries are exercised.
Match redirect hosts case-insensitively and test www and port
All checks were successful
CI / check (pull_request) Successful in 11s
2393203754
Claude merged commit 119ee960b0 into site-hardening 2026-10-07 14:17:06 +00:00
Claude deleted branch cc-8-domain 2026-10-07 14:17:06 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rob/CamperCan!13
No description provided.