-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
thuang-765-next-js #926
thuang-765-next-js #926
Changes from all commits
b882cf6
b0ff7a9
e4a6dc0
9f09e09
b635771
2f67235
2938a42
16bcf03
1ede997
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# WARNING: PLEASE MAKE SURE TO KEEP THIS FILE IN SYNC WITH `.dockerignore` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this warning is very important!! Otherwise RDEV might not work, because In our case, I updated |
||
|
||
# Logs | ||
logs | ||
*.log | ||
|
@@ -58,16 +60,16 @@ typings/ | |
# configs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nextjs and Gatsby need different .gitignore config |
||
src/configs/configs.js | ||
|
||
# gatsby files | ||
.cache/ | ||
public | ||
|
||
# Mac files | ||
.DS_Store | ||
|
||
# Yarn | ||
yarn-error.log | ||
.pnp/ | ||
.pnp.js | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# Next.js | ||
.next |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ package.json | |
package-lock.json | ||
public | ||
venv | ||
.next |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Babel config is now needed, since Nextjs doesn't use the plugin paradigm that Gatsby uses. This setting works along side with https://github.com/styled-components/babel-plugin-styled-components#readme |
||
plugins: [ | ||
[ | ||
"styled-components", | ||
{ | ||
displayName: true, | ||
preprocess: false, | ||
ssr: true, | ||
}, | ||
], | ||
], | ||
presets: ["next/babel"], | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ if [ ! -e ./node_modules ]; then | |
fi | ||
ln -sf /opt/node_app/node_modules/* /opt/node_app/node_modules/.bin ./node_modules/. | ||
if [ ! -z "$API_URL" ]; then | ||
cat src/configs/rdev.js | envsubst > src/configs/configs.js | ||
cat src/configs/rdev.js | envsubst >src/configs/configs.js | ||
else | ||
cp src/configs/local.js src/configs/configs.js | ||
fi | ||
|
@@ -21,8 +21,11 @@ fi | |
|
||
# Build and run without dev mode in remote dev env. | ||
if [ "${DEPLOYMENT_STAGE}" == "dev" ]; then | ||
exec gatsby develop --host 0.0.0.0 | ||
exec npm run dev | ||
else | ||
npm run build | ||
exec gatsby serve --host 0.0.0.0 | ||
# We need "-- --" because `npm run build-and-start-prod` | ||
# runs `npm run build && npm run serve` under the hood, | ||
# so we need to pass `-- -p 9000` to `npm run serve`, which | ||
# will then call `next start -p 9000` correctly | ||
exec npm run build-and-start-prod -- -- -p 9000 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this basically tells Next.js to run on port 9000 |
||
fi |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
const babelOptions = { | ||
presets: [ | ||
"@babel/preset-react", | ||
"babel-preset-gatsby", | ||
"@babel/preset-typescript", | ||
], | ||
presets: ["@babel/preset-react", "@babel/preset-typescript"], | ||
}; | ||
|
||
module.exports = require("babel-jest").createTransformer(babelOptions); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/// <reference types="next" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nextjs's own config setup. Autogenerated |
||
/// <reference types="next/types/global" /> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const withImages = require("next-images"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nextjs config file for CSP and image processing, such as SVG |
||
|
||
const configs = require(__dirname + "/src/configs/configs.js"); | ||
const nodeEnv = require(__dirname + "/src/common/constants/nodeEnv.js"); | ||
|
||
const { createSecureHeaders } = require("next-secure-headers"); | ||
|
||
const isProdBuild = process.env.NODE_ENV === nodeEnv.PRODUCTION; | ||
|
||
const SCRIPT_SRC = ["'self'"]; | ||
|
||
module.exports = withImages({ | ||
future: { webpack5: true }, | ||
|
||
headers() { | ||
return [ | ||
{ | ||
headers: createSecureHeaders({ | ||
contentSecurityPolicy: { | ||
directives: { | ||
baseUri: "'self'", | ||
connectSrc: [ | ||
"'self'", | ||
"sentry.prod.si.czi.technology", | ||
configs.API_URL, | ||
], | ||
defaultSrc: ["'self'"], | ||
fontSrc: ["'self'", "https://fonts.gstatic.com"], | ||
formAction: "'self'", | ||
frameAncestors: ["'none'"], | ||
imgSrc: ["'self'", "data:"], | ||
manifestSrc: ["'self'"], | ||
mediaSrc: ["'self'"], | ||
objectSrc: ["'none'"], | ||
reportURI: | ||
configs.SENTRY_DEPLOYMENT_ENVIRONMENT && | ||
"https://sentry.prod.si.czi.technology/api/167/security/?sentry_key=0432f3b3ceba4bc08d28dfb61fa29707&sentry_environment=" + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only send CSP violation to our new DP Sentry endpoint in deployed environments Mostly followed https://oslavdev.medium.com/protect-your-next-js-app-with-security-headers-7f70f4a95d63 |
||
configs.SENTRY_DEPLOYMENT_ENVIRONMENT, | ||
scriptSrc: isProdBuild | ||
? SCRIPT_SRC | ||
: [...SCRIPT_SRC, "'unsafe-eval'"], | ||
styleSrc: [ | ||
"'self'", | ||
"'unsafe-inline'", | ||
"https://fonts.googleapis.com", | ||
], | ||
upgradeInsecureRequests: true, | ||
workerSrc: true, | ||
}, | ||
}, | ||
}), | ||
source: "/(.*)", | ||
}, | ||
]; | ||
}, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prettier change and s/8000/3000