Repository navigation
Expand file tree
/
Copy pathnext.config.ts
More file actions
75 lines (69 loc) · 2.99 KB
/
Copy pathnext.config.ts
File metadata and controls
75 lines (69 loc) · 2.99 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import type { NextConfig } from "next";
const isProduction = process.env.NODE_ENV === "production";
const contentSecurityPolicy = [
"default-src 'self'",
"script-src 'self' 'unsafe-inline'",
"style-src 'self' 'unsafe-inline'",
"img-src 'self' data: blob: https:",
"font-src 'self' data: https:",
"object-src 'none'",
// blob: three.js fetches the textures packed inside a .glb through blob URLs
"connect-src 'self' blob:",
"frame-ancestors 'none'",
"base-uri 'self'",
"form-action 'self'",
// No upgrade-insecure-requests: HSTS already forces https online, and Safari would push http://localhost assets to https.
].join("; ");
const nextConfig: NextConfig = {
allowedDevOrigins: ["127.0.0.1"],
// English pages have no prefix: their files live in app/[lang], which needs one
async rewrites() {
return {
// Before files: later on Vercel has already turned the client requests for "/" into "/index.rsc", which has no match
beforeFiles: [{ source: "/", destination: "/en" }],
afterFiles: [{ source: "/:path((?!(?:it|en|og|_next)(?:/|$)).+)", destination: "/en/:path" }],
fallback: [],
};
},
async redirects() {
return [
{ source: "/en", destination: "/", permanent: true },
{ source: "/en/:path*", destination: "/:path*", permanent: true },
{ source: "/progetti", destination: "/it/projects", permanent: true },
{ source: "/progetti/pdm-system", destination: "/it/projects/hrm-gestionale", permanent: true },
{ source: "/progetti/:slug", destination: "/it/projects/:slug", permanent: true },
{ source: "/projects/product-user-manager", destination: "/projects", permanent: true },
{ source: "/projects/martina-cangemi", destination: "/projects/portfolio-tattoo", permanent: true },
{ source: "/it/projects/product-user-manager", destination: "/it/projects", permanent: true },
{ source: "/it/projects/martina-cangemi", destination: "/it/projects/portfolio-tattoo", permanent: true },
];
},
async headers() {
const commonHeaders = [
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
{ key: "X-Content-Type-Options", value: "nosniff" },
{ key: "X-Frame-Options", value: "DENY" },
{ key: "X-DNS-Prefetch-Control", value: "on" },
{ key: "X-Permitted-Cross-Domain-Policies", value: "none" },
{ key: "Cross-Origin-Opener-Policy", value: "same-origin" },
{ key: "Cross-Origin-Resource-Policy", value: "same-site" },
{
key: "Permissions-Policy",
value: "camera=(), microphone=(), geolocation=(), interest-cohort=()",
},
];
const productionOnlyHeaders = isProduction
? [
{ key: "Strict-Transport-Security", value: "max-age=31536000; includeSubDomains; preload" },
{ key: "Content-Security-Policy", value: contentSecurityPolicy },
]
: [];
return [
{
source: "/(.*)",
headers: [...commonHeaders, ...productionOnlyHeaders],
},
];
},
};
export default nextConfig;