Skip to content

Commit

Permalink
chore(cors): Support new LAGO_DOMAIN (#1849)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdenquin authored Nov 5, 2024
1 parent 0967bb3 commit f74e6e5
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 23 deletions.
4 changes: 3 additions & 1 deletion .env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ rm -rf ./env-config.js
touch ./env-config.js

api_url_value=$(echo $API_URL)
domain_value=$(echo $LAGO_DOMAIN)
app_env_value=$(echo $APP_ENV)
lago_oauth_proxy_url_value=$(echo $LAGO_OAUTH_PROXY_URL)
lago_disable_signup_value=$(echo $LAGO_DISABLE_SIGNUP)
nango_public_key=$(echo $NANGO_PUBLIC_KEY)
sentry_dsn_value=$(echo $SENTRY_DSN)

echo "window.API_URL = \"$api_url_value\"" >> ./env-config.js
echo "window.LAGO_DOMAIN = \"$domain_value\"" >> ./env-config.js
echo "window.APP_ENV = \"$app_env_value\"" >> ./env-config.js
echo "window.LAGO_OAUTH_PROXY_URL = \"$lago_oauth_proxy_url_value\"" >> ./env-config.js
echo "window.LAGO_DISABLE_SIGNUP = \"$lago_disable_signup_value\"" >> ./env-config.js
echo "window.NANGO_PUBLIC_KEY = \"$nango_public_key\"" >> ./env-config.js
echo "window.SENTRY_DSN = \"$sentry_dsn_value\"" >> ./env-config.js
echo "window.SENTRY_DSN = \"$sentry_dsn_value\"" >> ./env-config.js
43 changes: 22 additions & 21 deletions globals.d.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
interface Window {
Cypress: any;
Lago: any;
interface Window {
Cypress: any
Lago: any
}

declare type AppEnvEnum = import('./src/core/constants/globalTypes').AppEnvEnum

declare var APP_ENV: AppEnvEnum
declare var API_URL: string;
declare var APP_VERSION: string;
declare var LAGO_OAUTH_PROXY_URL: string;
declare var LAGO_DISABLE_SIGNUP: string;
declare var NANGO_PUBLIC_KEY: string;
declare var SENTRY_DSN: string;
declare var API_URL: string
declare var LAGO_DOMAIN: string
declare var APP_VERSION: string
declare var LAGO_OAUTH_PROXY_URL: string
declare var LAGO_DISABLE_SIGNUP: string
declare var NANGO_PUBLIC_KEY: string
declare var SENTRY_DSN: string

declare module "*.svg" {
const content: any;
export default content;
declare module '*.svg' {
const content: any
export default content
}
declare module "*.png" {
const value: any;
export default value;
declare module '*.png' {
const value: any
export default value
}

declare module "*.jpg" {
const value: any;
export default value;
declare module '*.jpg' {
const value: any
export default value
}

declare module "*.jpeg" {
const value: any;
export default value;
declare module '*.jpeg' {
const value: any
export default value
}
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ module.exports = {
globals: {
APP_ENV: 'production',
API_URL: 'http://localhost:3000',
DOMAIN: 'localhost',
APP_VERSION: '1.0.0',
IS_REACT_ACT_ENVIRONMENT: true,
LAGO_OAUTH_PROXY_URL: 'https://proxy.lago.dev',
Expand Down
8 changes: 7 additions & 1 deletion src/core/apolloClient/reactiveVars/envGlobalVar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ interface EnvGlobal {
sentryDsn: string
}

var apiUrl = !!window.API_URL
? window.API_URL
: !!window.LAGO_DOMAIN
? `https://${window.LAGO_DOMAIN}/api`
: API_URL

export const envGlobalVar = makeVar<EnvGlobal>({
apiUrl,
appEnv: window.APP_ENV || APP_ENV,
apiUrl: window.API_URL || API_URL,
lagoOauthProxyUrl: window.LAGO_OAUTH_PROXY_URL || LAGO_OAUTH_PROXY_URL,
disableSignUp: (window.LAGO_DISABLE_SIGNUP || LAGO_DISABLE_SIGNUP) === 'true',
appVersion: APP_VERSION,
Expand Down
1 change: 1 addition & 0 deletions webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = () => {
new webpack.DefinePlugin({
APP_ENV: JSON.stringify(APP_ENV),
API_URL: JSON.stringify(process.env.API_URL),
DOMAIN: JSON.stringify(process.env.LAGO_DOMAIN),
APP_VERSION: JSON.stringify(version),
LAGO_OAUTH_PROXY_URL: JSON.stringify(process.env.LAGO_OAUTH_PROXY_URL),
LAGO_DISABLE_SIGNUP: JSON.stringify(process.env.LAGO_DISABLE_SIGNUP),
Expand Down

0 comments on commit f74e6e5

Please sign in to comment.