From d171c2a551ea470ae1c5941ff0af72259d32818d Mon Sep 17 00:00:00 2001 From: Spencer Flagg Date: Sun, 12 Dec 2021 19:53:33 +0100 Subject: [PATCH] removed env string logic --- login/index.js | 32 ++++++++++++++++---------------- nuxt.config.js | 38 +++++++++++++++++++------------------- plugins/env.js | 15 +-------------- 3 files changed, 36 insertions(+), 49 deletions(-) diff --git a/login/index.js b/login/index.js index 4164711..9bc43f8 100644 --- a/login/index.js +++ b/login/index.js @@ -8,18 +8,18 @@ import { PortierClient } from "portier"; const cookieParser = require('cookie-parser'); -const baseURL = function () { - switch (process.env.FLYLOCAL_ENV) { - case "prod": - return process.env.PROD_URL; - case "dev": - return process.env.DEV_URL; - case "local": - return "http://" + process.env.LOCAL_IP + ":" + process.env.LOCAL_PORT; - default: - break; - } -}; +// const baseURL = function () { +// switch (process.env.FLYLOCAL_ENV) { +// case "prod": +// return process.env.PROD_URL; +// case "dev": +// return process.env.DEV_URL; +// case "local": +// return "http://" + process.env.LOCAL_IP + ":" + process.env.LOCAL_PORT; +// default: +// break; +// } +// }; // GET / Render homepage // POST /login Redirect to the broker and begin authentication @@ -29,7 +29,7 @@ const baseURL = function () { const portier = new PortierClient({ //broker: process.env.PORTIER_URL, - redirectUri: "https://flylocal.us/login/verify", + redirectUri: process.env.BASE_URL + "/login/verify", }); @@ -225,7 +225,7 @@ app.get("/", (req, res) => { app.post("/auth", formParser, (req, res) => { console.log("auth"); - console.log(baseURL()); + //console.log(baseURL()); //console.log(req.body); portier.authenticate(req.body.email).then((authUrl) => { @@ -241,11 +241,11 @@ app.post("/verify", formParser, (req, res) => { //console.log(req.body); console.log("verify"); - console.log(baseURL()); + //console.log(baseURL()); portier.verify(req.body.id_token).then((email) => { - const redirectButton = (req.query.redirect && typeof req.query.redirect !== 'undefined') ? `back to your flight` : `back to the map`; + const redirectButton = (req.query.redirect && typeof req.query.redirect !== 'undefined') ? `back to your flight` : `back to the map`; // needed to string .cookie and .type together res.cookie('email', email, diff --git a/nuxt.config.js b/nuxt.config.js index 7b8a9fa..fa9af48 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -1,21 +1,21 @@ -const baseURL = function() { - switch (process.env.FLYLOCAL_ENV) { - case "prod": - return process.env.PROD_URL; - case "dev": - return process.env.DEV_URL; - case "local": - return "http://" + process.env.LOCAL_IP + ":" + process.env.LOCAL_PORT; - default: - break; - } -}; +// const baseURL = function() { +// switch (process.env.FLYLOCAL_ENV) { +// case "prod": +// return process.env.PROD_URL; +// case "dev": +// return process.env.DEV_URL; +// case "local": +// return "http://" + process.env.LOCAL_IP + ":" + process.env.LOCAL_PORT; +// default: +// break; +// } +// }; export default { - env: { - baseURL: baseURL() - }, + // env: { + // baseURL: baseURL() + // }, // Global page headers: https://go.nuxtjs.dev/config-head head: { @@ -27,16 +27,16 @@ export default { { name: 'format-detection', content: 'telephone=no' }, { itemprop: 'name', content: 'Small Planes, Big Experiences' }, { itemprop: 'description', content: 'FlyLocal is the best way to find local airlines that fly throughout the great state of Alaska. Explore the \'Last Frontier\' with FlyLocal.' }, - { itemprop: 'image', content: baseURL() + '/screenshot.png' }, - { property: 'og:url', content: baseURL() }, + { itemprop: 'image', content: process.env.BASE_URL + '/screenshot.png' }, + { property: 'og:url', content: process.env.BASE_URL }, { property: 'og:type', content: 'website' }, { property: 'og:title', content: 'Small Planes, Big Experiences' }, { property: 'og:description', content: 'FlyLocal is the best way to find local airlines that fly throughout the great state of Alaska. Explore the \'Last Frontier\' with FlyLocal.' }, - { property: 'og:image', content: baseURL() + '/screenshot.png' }, + { property: 'og:image', content: process.env.BASE_URL + '/screenshot.png' }, { name: 'twitter:card', content: 'summary_large_image' }, { name: 'twitter:title', content: 'Small Planes, Big Experiences' }, { name: 'twitter:description', content: 'FlyLocal is the best way to find local airlines that fly throughout the great state of Alaska. Explore the \'Last Frontier\' with FlyLocal.' }, - { name: 'twitter:image', content: baseURL() + '/screenshot.png' } + { name: 'twitter:image', content: process.env.BASE_URL + '/screenshot.png' } ], link: [ { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' } diff --git a/plugins/env.js b/plugins/env.js index 50d5057..5f1b9bd 100644 --- a/plugins/env.js +++ b/plugins/env.js @@ -1,18 +1,5 @@ -const BASE_URL = function () { - switch (process.env.FLYLOCAL_ENV) { - case "prod": - return process.env.PROD_URL; - case "dev": - return process.env.DEV_URL; - case "local": - return "http://" + process.env.LOCAL_IP + ":" + process.env.LOCAL_PORT; - default: - break; - } -} - export default ({ app }, inject) => { // Inject $hello(msg) in Vue, context and store. - inject('BASE_URL', () => BASE_URL()) + inject('BASE_URL', () => process.env.BASE_URL) inject('hello', msg => console.log(`Hello ${msg}!`)) }