Skip to content

Commit

Permalink
Revert "Merge pull request #78 from ThangHuuVu/chore/upgrade-next-12"
Browse files Browse the repository at this point in the history
This reverts commit 1cdf730, reversing
changes made to 1170c03.
  • Loading branch information
ThangHuuVu committed Oct 28, 2021
1 parent 7e2f655 commit 5127101
Show file tree
Hide file tree
Showing 5 changed files with 901 additions and 886 deletions.
63 changes: 62 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,59 @@ const SentryWebpackPluginOptions = {
silent: true,
};

// https://securityheaders.com
// https://csp-evaluator.withgoogle.com/
const ContentSecurityPolicy = `
default-src 'self';
script-src 'self' 'unsafe-eval' 'unsafe-inline' *.twitter.com https://www.googletagmanager.com https://www.google-analytics.com https://dbdiagram.io;
child-src *.youtube.com *.google.com *.twitter.com https://codepen.io https://dbdiagram.io;
style-src 'self' 'unsafe-inline' *.googleapis.com;
img-src * blob: data: www.googletagmanager.com;
media-src 'self';
connect-src *;
font-src 'self';
object-src 'none';
worker-src 'self' *.youtube.com *.google.com *.twitter.com;
`;
const securityHeaders = [
// https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP
{
key: "Content-Security-Policy",
value: ContentSecurityPolicy.replace(/\n/g, ""),
},
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy
{
key: "Referrer-Policy",
value: "origin-when-cross-origin",
},
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
{
key: "X-Frame-Options",
value: "SAMEORIGIN",
},
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options
{
key: "X-Content-Type-Options",
value: "nosniff",
},
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-DNS-Prefetch-Control
{
key: "X-DNS-Prefetch-Control",
value: "on",
},
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security
{
key: "Strict-Transport-Security",
value: "max-age=31536000; includeSubDomains; preload",
},
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Feature-Policy
// Opt-out of Google FLoC: https://amifloced.org/
{
key: "Permissions-Policy",
value: "interest-cohort=()",
},
];

const isDevelopment = process.env.NODE_ENV === "development";

// @ts-check
Expand All @@ -18,7 +71,6 @@ const isDevelopment = process.env.NODE_ENV === "development";
* @type {import('next').NextConfig}
**/
const nextConfig = {
swcMinify: true,
reactStrictMode: true,
pageExtensions: ["ts", "tsx", "md", "mdx"],
images: {
Expand All @@ -37,6 +89,15 @@ const nextConfig = {
"s3.us-west-2.amazonaws.com",
],
},
webpack5: true,
async headers() {
return [
{
source: "/(.*)",
headers: securityHeaders,
},
];
},
pwa: {
dest: "public",
runtimeCaching,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"scripts": {
"start": "next-remote-watch ./data",
"dev": "TAILWIND_MODE=watch next dev",
"dev": "yarn run clean && TAILWIND_MODE=watch next dev",
"build": "next build && node ./scripts/generate-sitemap",
"clean": "rm -rf ./.next",
"serve": "next start",
Expand Down Expand Up @@ -35,7 +35,7 @@
"image-size": "0.9.7",
"mdx-bundler": "^6.0.1",
"mdx-embed": "^0.0.19",
"next": "^12.0.1",
"next": "^11.1.2",
"next-auth": "4.0.0-beta.5",
"next-pwa": "^5.3.1",
"next-seo": "4.23.0",
Expand Down
28 changes: 0 additions & 28 deletions pages/_middleware.ts

This file was deleted.

3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
"@/layouts/*": ["layouts/*"],
"@/lib/*": ["lib/*"],
"@/css/*": ["css/*"]
},
"incremental": true
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
Expand Down
Loading

0 comments on commit 5127101

Please sign in to comment.