Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
willwill96 committed May 19, 2020
1 parent 353a58e commit d044323
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "@connexta/revelio",
"version": "2.0.0",
"scripts": {
"dev": "next",
"dev": "cross-env NODE_ENV=development node src/server.js",
"build": "next build",
"build:storybook": "build-storybook -c .storybook -o target/storybook",
"start": "next start",
"start": "cross-env NODE_ENV=production node src/server.js",
"fmt": "prettier \"**/*.{js,jsx,ts,tsx,json}\" --write",
"storybook": "start-storybook -p 8081 -c .storybook",
"lint": "eslint .",
Expand Down
5 changes: 4 additions & 1 deletion app/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const fs = require('fs')
const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()
// @ts-ignore

process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0
const httpsOptions = {
key: fs.readFileSync('../server.key'),
Expand All @@ -14,6 +14,9 @@ const httpsOptions = {

app.prepare().then(() => {
createServer(httpsOptions, (req, res) => {
if (req.protocol === 'http') {
res.redirect('https://' + req.headers.host + req.url)
}
const parsedUrl = parse(req.url, true)
handle(req, res, parsedUrl)
}).listen(3000, err => {
Expand Down
7 changes: 7 additions & 0 deletions graphql/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ app.use(compression())

app.use('/graphql', apolloServer)

const httpsRedirect = (req: any, res: any) => {
if (req.protocol === 'http') {
res.redirect('https://' + req.headers.host + req.url)
}
}

app.use('*', httpsRedirect)
https
.createServer(
{
Expand Down

0 comments on commit d044323

Please sign in to comment.