-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnext.config.ts
More file actions
109 lines (99 loc) · 3.35 KB
/
Copy pathnext.config.ts
File metadata and controls
109 lines (99 loc) · 3.35 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import type { NextConfig } from "next";
const iomServerUrl =
process.env.NEXT_PUBLIC_IOM_SERVER_URL || "http://localhost:5600";
const connectOrigins = (() => {
try {
const origin = new URL(iomServerUrl).origin;
if (origin.startsWith("https://"))
return `${origin} ${origin.replace("https://", "wss://")}`;
return origin;
} catch {
return "";
}
})();
const cspHeader = `
default-src 'self';
script-src 'self' 'unsafe-eval' 'unsafe-inline' https://challenges.cloudflare.com https://cdnjs.cloudflare.com https://cdn.jsdelivr.net;
worker-src 'self' blob: https://cdnjs.cloudflare.com https://cdn.jsdelivr.net;
frame-src 'self' https://challenges.cloudflare.com https://storage.googleapis.com https://*.googleapis.com;
style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://*.googleapis.com;
img-src 'self' blob: data: http://localhost:* ${connectOrigins} https://storage.googleapis.com https://*.googleapis.com;
font-src 'self' https://fonts.gstatic.com https://*.googleapis.com;
connect-src 'self' http://localhost:* ${connectOrigins} https://cdnjs.cloudflare.com https://cdn.jsdelivr.net https://storage.googleapis.com https://*.googleapis.com;
object-src 'none';
base-uri 'self';
form-action 'self';
frame-ancestors 'none';
upgrade-insecure-requests;
`.replace(/\n/g, "");
const nextConfig: NextConfig = {
eslint: { ignoreDuringBuilds: true },
typescript: { ignoreBuildErrors: true },
images: { unoptimized: true },
async rewrites() {
const routes = [
{
hosts: [
"moa.betterinternship.com",
"dev.moa.betterinternship.com",
"moa.localhost",
],
destination: "company",
},
{
hosts: [
"uni.betterinternship.com",
"dev.uni.betterinternship.com",
"uni.localhost",
],
destination: "university",
},
{
hosts: [
"admin.iom.betterinternship.com",
"dev.admin.iom.betterinternship.com",
"admin.iom.localhost",
],
destination: "admin",
},
];
const rewrites: {
source: string;
has: { type: "host"; value: string }[];
destination: string;
}[] = [];
routes.forEach(({ hosts, destination }) => {
hosts.forEach((host) => {
rewrites.push({
source:
"/:path((?!_next|betterinternship-logo|BetterInternshipLogo|bg2(?:\\.png)?(?:/|$)|company(?:/|$)|university(?:/|$)|admin(?:/|$)|gcs-proxy(?:/|$)|invite(?:/|$)|sign(?:/|$)|robots\\.txt(?:/|$)).*)*",
has: [{ type: "host", value: host }],
destination: `/${destination}/:path*`,
});
});
});
return { beforeFiles: rewrites };
},
async headers() {
return [
{
source: "/(.*)",
headers: [
{ key: "Content-Security-Policy", value: cspHeader },
{
key: "Strict-Transport-Security",
value: "max-age=63072000; includeSubDomains; preload",
},
{ key: "X-Frame-Options", value: "DENY" },
{ key: "X-Content-Type-Options", value: "nosniff" },
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
{
key: "Permissions-Policy",
value: "camera=(), microphone=(), geolocation=()",
},
],
},
];
},
};
export default nextConfig;