diff options
Diffstat (limited to 'application')
-rw-r--r-- | application/components/github/api.js | 10 | ||||
-rw-r--r-- | application/config.js | 14 |
2 files changed, 14 insertions, 10 deletions
diff --git a/application/components/github/api.js b/application/components/github/api.js index 97032e6..61adb7b 100644 --- a/application/components/github/api.js +++ b/application/components/github/api.js @@ -1,5 +1,5 @@ +import axios from 'axios' import EventEmitter from 'eventemitter3' -const axios = require('axios') import * as config from '../../config' @@ -44,9 +44,9 @@ export class API extends EventEmitter { } const installationUrl = `${config.apiBaseUrl}/github/installation` - const param = new URLSearchParams(location.search).get('token') + const param = new URLSearchParams(window.location.search).get('token') if (!localStorage.auth_token && param) { - history.replaceState({}, null, location.pathname) + window.history.replaceState({}, null, window.location.pathname) localStorage.auth_token = param } @@ -68,11 +68,11 @@ export class API extends EventEmitter { beginLoginFlow() { localStorage.removeItem('auth_token') - location.href = `${config.apiBaseUrl}/github/authorize` + window.location.href = `${config.apiBaseUrl}/github/authorize` } beginInstallAppFlow() { - location.href = `https://github.com/apps/${config.githubAppName}/installations/new` + window.location.href = `https://github.com/apps/${config.githubAppName}/installations/new` } isGitHubAuthorized() { diff --git a/application/config.js b/application/config.js index 8b513cc..eae363c 100644 --- a/application/config.js +++ b/application/config.js @@ -2,8 +2,12 @@ function parseBoolean (val) { return val && ['1', 'on', 'yes', 'true'].includes(val.toString().toLowerCase()) } -export const apiBaseUrl = process.env.API_BASE_URL -export const appBaseUrl = process.env.APP_BASE_URL -export const githubAppName = process.env.GITHUB_APP_NAME -export const enableGitHub = parseBoolean(process.env.ENABLE_GITHUB) -export const enableLocal = parseBoolean(process.env.ENABLE_LOCAL) +function env(key) { + return process.env[key] || process.env[`REACT_APP_${key}`] +} + +export const apiBaseUrl = env('API_BASE_URL') +export const appBaseUrl = env('APP_BASE_URL') +export const githubAppName = env('GITHUB_APP_NAME') +export const enableGitHub = parseBoolean(env('ENABLE_GITHUB')) +export const enableLocal = parseBoolean(env('ENABLE_LOCAL')) |