...
 
Commits (4)
......@@ -27,3 +27,4 @@ functions-build/*.js
# Local Netlify folder
.netlify
.env
'use strict'
require('dotenv').config()
if (false) {
require('.env') // So the file is included by netlify zip it and ship it
}
const awsServerlessExpress = require('aws-serverless-express')
const express = require('express')
......@@ -25,6 +29,7 @@ const app = express()
// Correct host when lambda is executed by netlify
app.use((req, res, next) => {
const url = new global.URL(DEPLOY_PRIME_URL || DEPLOY_URL || URL);
console.log({DEPLOY_PRIME_URL, DEPLOY_URL, URL});
req.headers.host = url.host;
next();
})
......
......@@ -11,6 +11,7 @@
"bootswatch": "4.3.1",
"classnames": "^2.2.6",
"d3": "^4.10.2",
"dotenv": "^8.2.0",
"graphql": "^14.2.1",
"moment": "^2.22.2",
"netlify-lambda": "^1.6.3",
......@@ -38,7 +39,7 @@
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"prebuild": "netlify-lambda build functions",
"prebuild": "node write_env.js && netlify-lambda build functions",
"postinstall": "netlify-lambda install"
},
"devDependencies": {
......
const fs = require('fs');
fs.writeFileSync('.env', Object.keys(process.env).map(key => `${key}=${process.env[key]}`).join('\n'));
......@@ -5145,6 +5145,10 @@ [email protected]:
version "4.0.0"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-4.0.0.tgz#864ef1379aced55ce6f95debecdce179f7a0cd1d"
[email protected]^8.2.0:
version "8.2.0"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.2.0.tgz#97e619259ada750eea3e4ea3e26bceea5424b16a"
[email protected]^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2"
......