Browse Source

removed env string logic

master
Spencer Flagg 3 years ago
parent
commit
d171c2a551
3 changed files with 36 additions and 49 deletions
  1. +16
    -16
      login/index.js
  2. +19
    -19
      nuxt.config.js
  3. +1
    -14
      plugins/env.js

+ 16
- 16
login/index.js View File

@ -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') ? `<a class="btn btn--primary" href="${req.query.redirect}">back to your flight</a>` : `<a class="btn btn--primary" href="${baseURL()}">back to the map</a>`;
const redirectButton = (req.query.redirect && typeof req.query.redirect !== 'undefined') ? `<a class="btn btn--primary" href="${req.query.redirect}">back to your flight</a>` : `<a class="btn btn--primary" href="${process.env.BASE_URL}">back to the map</a>`;
// needed to string .cookie and .type together
res.cookie('email', email,

+ 19
- 19
nuxt.config.js View File

@ -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' }

+ 1
- 14
plugins/env.js View File

@ -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}!`))
}

Loading…
Cancel
Save