Skip to content

Commit

Permalink
chore: add env variables for vercel setup
Browse files Browse the repository at this point in the history
  • Loading branch information
moonflare committed Apr 29, 2020
1 parent e4c5dff commit 82699fc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
30 changes: 30 additions & 0 deletions frontend/env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const fs = require("fs");

const ENVs = {
test: {
REACT_APP_IDP_URL: "https://dev-is.stamacasa.ro",
REACT_APP_URL: "http://localhost:3000",
REACT_APP_API_URL: "https://dev-api.stamacasa.ro"
},
development: {
REACT_APP_IDP_URL: "http://localhost:5001",
REACT_APP_URL: "http://localhost:3000",
REACT_APP_API_URL: "http://localhost:5008"
}
};

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

const content = `window._env_ = {
REACT_APP_IDP_URL: "${ENVs[env].REACT_APP_IDP_URL}",
REACT_APP_URL: "${ENVs[env].REACT_APP_URL}",
REACT_APP_API_URL: "${ENVs[env].REACT_APP_API_URL}",
CLIENT_ID: "js"
};`;

try {
fs.writeFileSync("./public/env-config.js", content);
console.info("🚀 File `env-config.js` written successfully");
} catch (err) {
console.error(err);
}
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"build-test": "NODE_ENV=test node env.js && npm run build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"lint": "eslint ./src --ext .js,.jsx,.ts,.tsx",
Expand Down

0 comments on commit 82699fc

Please sign in to comment.