Skip to content

Commit db695d1

Browse files
committed
Fix website routing by splitting Caddyfile into separate site blocks
The single :80 site block with a host matcher was losing to the catch-all explorer handler due to Caddy's handle sorting by path specificity. Split into a dedicated http://basalt.foundation block and a generic :80 block so Caddy routes by hostname unambiguously. Extract shared security headers into a reusable snippet.
1 parent dd2907d commit db695d1

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

deploy/testnet/Caddyfile

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,26 @@
22
# Cloudflare Tunnel terminates HTTPS. Caddy handles routing, CORS, and headers.
33
# Two domains: basalt.foundation (website) and testnet.basalt.foundation (testnet).
44

5-
# ─── Website (basalt.foundation) ───────────────────────────────────
6-
:80 {
7-
# Match website domain first; fall through to testnet for other hosts
8-
@website host basalt.foundation
9-
handle @website {
10-
reverse_proxy website:80
5+
(security_headers) {
6+
header {
7+
X-Content-Type-Options nosniff
8+
X-Frame-Options DENY
9+
Referrer-Policy strict-origin-when-cross-origin
10+
-Server
1111
}
12+
header Access-Control-Allow-Origin *
13+
header Access-Control-Allow-Methods "GET, POST, OPTIONS"
14+
header Access-Control-Allow-Headers "Content-Type"
15+
}
1216

13-
# ─── Testnet (testnet.basalt.foundation or any other host) ─────
17+
# ─── Website (basalt.foundation) ───────────────────────────────────
18+
http://basalt.foundation {
19+
reverse_proxy website:80
20+
import security_headers
21+
}
1422

23+
# ─── Testnet (testnet.basalt.foundation or any other host) ─────────
24+
:80 {
1525
# REST API
1626
handle /v1/* {
1727
reverse_proxy validator-0:5000
@@ -39,16 +49,5 @@
3949
reverse_proxy explorer:80
4050
}
4151

42-
# Security headers
43-
header {
44-
X-Content-Type-Options nosniff
45-
X-Frame-Options DENY
46-
Referrer-Policy strict-origin-when-cross-origin
47-
-Server
48-
}
49-
50-
# CORS
51-
header Access-Control-Allow-Origin *
52-
header Access-Control-Allow-Methods "GET, POST, OPTIONS"
53-
header Access-Control-Allow-Headers "Content-Type"
52+
import security_headers
5453
}

0 commit comments

Comments
 (0)