Repository navigation
Expand file tree
/
Copy pathnext.config.js
More file actions
54 lines (53 loc) · 2.42 KB
/
Copy pathnext.config.js
File metadata and controls
54 lines (53 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/** @type {import('next').NextConfig} */
const nextConfig = {
// Basic hardening headers on every route. A full Content-Security-Policy
// is a bigger, separate effort (it would need to account for MapTiler
// tiles, Supabase, Vercel Analytics, and the Leaflet/OG image pipelines)
// and is left for a follow-up.
async headers() {
return [
{
// Every route except /embed. The blanket rule has to leave /embed out: a later, more
// specific rule cannot remove a header the earlier one set, and /embed was being
// served with both `X-Frame-Options: DENY` and `frame-ancestors *`. Browsers that
// let frame-ancestors win framed it; any that honoured DENY would not.
source: "/((?!embed(?:/|$)).*)",
headers: [
{ key: "X-Content-Type-Options", value: "nosniff" },
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
// geolocation stays enabled for this origin - the "Near me"
// feature genuinely uses it. Everything else this app doesn't
// use is disabled.
{
key: "Permissions-Policy",
value: "camera=(), microphone=(), geolocation=(self)",
},
// Nothing in the app needs to be iframed - except /embed below,
// which is a deliberate, narrow carve-out.
{ key: "X-Frame-Options", value: "DENY" },
],
},
{
// The embeddable map widget (see /docs/embedding-widget) is the one
// page meant to be framed by other sites. It renders no account
// state - public map data only - so allowing any origin to frame it
// isn't a privacy or clickjacking risk the way framing an
// authenticated page would be. The rule above skips this path, so no
// X-Frame-Options header is sent and `frame-ancestors` is the only
// framing policy. Anything added to /embed that reads account state
// needs a review of this carve-out first (see #311).
source: "/embed/:path*",
headers: [
{ key: "X-Content-Type-Options", value: "nosniff" },
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
{
key: "Permissions-Policy",
value: "camera=(), microphone=(), geolocation=()",
},
{ key: "Content-Security-Policy", value: "frame-ancestors *" },
],
},
];
},
};
module.exports = nextConfig;