-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnext.config.js
106 lines (102 loc) · 3.83 KB
/
next.config.js
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
/* eslint-disable no-restricted-syntax */
// TODO: Switch to hashes/nonce
const ContentSecurityPolicy = `
default-src 'self' vitals.vercel-insights.com giscus.app assets.hkamran.com data: u.13willow.com;
img-src 'self' assets.hkamran.com i.ibb.co;
script-src 'self' u.13willow.com;
style-src 'self' 'unsafe-inline' data:;
font-src 'self';
report-to https://hkamran.report-uri.com/r/d/csp/wizard;
report-uri https://hkamran.report-uri.com/r/d/csp/wizard;
`;
const securityHeaders = [
{
key: "X-Content-Type-Options",
value: "nosniff",
},
{
key: "X-Frame-Options",
value: "SAMEORIGIN",
},
{
key: "X-XSS-Protection",
value: "1; mode=block",
},
{
key: "X-DNS-Prefetch-Control",
value: "on",
},
{
key: "Strict-Transport-Security",
value: "max-age=63072000; includeSubDomains; preload",
},
{
key: "Referrer-Policy",
value: "strict-origin-when-cross-origin",
},
{
key: "Permissions-Policy",
value: "accelerometer=(), ambient-light-sensor=(), autoplay=(), battery=(), camera=(), cross-origin-isolated=(), display-capture=(), document-domain=(), encrypted-media=(), execution-while-not-rendered=(), execution-while-out-of-viewport=(), fullscreen=(), geolocation=(), gyroscope=(), keyboard-map=(), magnetometer=(), microphone=(), midi=(), navigation-override=(), payment=(), picture-in-picture=(), publickey-credentials-get=(), screen-wake-lock=(), sync-xhr=(), usb=(), web-share=(self), xr-spatial-tracking=(), clipboard-read=(), clipboard-write=(), gamepad=(), speaker-selection=(), conversion-measurement=(), focus-without-user-activation=(), hid=(), idle-detection=(), interest-cohort=(), serial=(), sync-script=(), trust-token-redemption=(), unload=(), window-placement=(), vertical-scroll=()",
},
{
key: "Content-Security-Policy",
value: ContentSecurityPolicy.replace(/\s{2,}/g, " ").trim(),
},
];
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
images: {
domains: ["assets.hkamran.com"],
},
webpack: (config) => {
config.experiments = { topLevelAwait: true, layers: true };
return config;
},
async headers() {
if (process.env.NODE_ENV !== "development") {
return [
{
source: "/:path*",
headers: securityHeaders,
},
];
} else {
return [];
}
},
async redirects() {
return [
{
source: "/blog/post/:slug",
destination: "/article/:slug",
permanent: true,
},
{ source: "/creations", destination: "/showcase", permanent: true },
{
source: "/creations/:slug",
destination: "/showcase/:slug",
permanent: true,
},
{
source: "/articles/:slug",
destination: "/tag/:slug",
permanent: true,
},
{
source: "/notes/:slug",
destination: "/tag/:slug",
permanent: true,
},
{ source: "/article", destination: "/articles", permanent: true },
{ source: "/note", destination: "/notes", permanent: true },
{ source: "/tag", destination: "/articles", permanent: true },
{source:"/feed", destination:"https://assets.hkamran.com/website/feed.rss",permanent:true},
{source:"/feed/:slug", destination:"https://assets.hkamran.com/website/feed.:slug",permanent:true},
];
},
};
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
});
module.exports = withBundleAnalyzer(nextConfig);