diff --git a/src/environment.ts b/src/environment.ts index 12d5d372..fbc3fc36 100644 --- a/src/environment.ts +++ b/src/environment.ts @@ -1,17 +1,19 @@ require('dotenv').config({ - path: './.env', + path: './web-app/.env', }) interface Environment { VERSION: string NODE_ENV: string LOG: boolean + API_URL: string } const environment: Environment = { VERSION: process.env.VERSION || 'unknown', NODE_ENV: process.env.NODE_ENV || 'production', LOG: (process.env.LOG || '').toLowerCase() === 'true', + API_URL: process.env.REACT_APP_GQL_URI || '', } export default environment diff --git a/src/webview/render.ts b/src/webview/render.ts index d609ac07..9e25e9bc 100644 --- a/src/webview/render.ts +++ b/src/webview/render.ts @@ -2,6 +2,7 @@ import { JSDOM } from 'jsdom' import * as path from 'path' import * as vscode from 'vscode' import onError from '../services/sentry/onError' +import environment from '../environment' const getNonce = (): string => { let text = '' @@ -72,7 +73,7 @@ async function render(panel: vscode.WebviewPanel, rootPath: string) { cspMeta.content = [ `default-src 'self'`, - `connect-src https: http:`, + `connect-src https: http: ${environment.API_URL}`, // @ts-ignore `font-src ${panel.webview.cspSource} http: https: data:`, // @ts-ignore diff --git a/web-app/src/environment.ts b/web-app/src/environment.ts index d77dc04b..ff5f11cf 100644 --- a/web-app/src/environment.ts +++ b/web-app/src/environment.ts @@ -1,13 +1,12 @@ // validate .env -// const requiredKeys = ['REACT_APP_GQL_URI'] -// for (const required of requiredKeys) { -// if (!process.env[required]) { -// throw new Error(`Missing Environmental Variables: ${required}`) -// } -// } +const requiredKeys = ['REACT_APP_GQL_URI'] +for (const required of requiredKeys) { + if (!process.env[required]) { + throw new Error(`Missing Environmental Variables: ${required}`) + } +} -export const GQL_URI: string = - process.env.REACT_APP_GQL_URI || 'https://33mf420q4m.execute-api.us-west-2.amazonaws.com/stage/api-stage' +export const GQL_URI: string = process.env.REACT_APP_GQL_URI || 'NO API URI PROVIDED' export const DEBUG: boolean = (process.env.REACT_APP_DEBUG || '').toLowerCase() === 'true' export const VERSION: string = process.env.VERSION || 'unknown' export const NODE_ENV: string = process.env.NODE_ENV || 'production'