* Fix CLINE_ENVIRONMENT configuration not being passed to webview ## Problem The CLINE_ENVIRONMENT configuration set in launch.json was not being properly passed to the webview, causing the webview to break when trying to access environment-specific configurations. This resulted in: Webview using incorrect API URLs (always defaulting to production) Broken authentication flows in development/staging environments Inconsistent behavior between the main extension and webview components ## Root Cause The issue occurred because: Duplicate Configuration Logic: The webview had its own separate config.ts file that was trying to read process.env.CLINE_ENVIRONMENT directly Environment Variable Propagation: While Vite was configured to pass CLINE_ENVIRONMENT to the build process, the webview's runtime code couldn't access this environment variable properly Configuration Mismatch: The main extension and webview were using different configuration sources, leading to inconsistent environment settings * fix credit uri * replace apiBaseUrl with appBaseUrl * local option * fallback changed to app * change to app url * merge fixes --------- Co-authored-by: 0xtoshii <94262432+0xToshii@users.noreply.github.com>
81 lines
2.2 KiB
TypeScript
81 lines
2.2 KiB
TypeScript
export enum Environment {
|
|
production = "production",
|
|
staging = "staging",
|
|
local = "local",
|
|
}
|
|
|
|
interface EnvironmentConfig {
|
|
appBaseUrl: string
|
|
apiBaseUrl: string
|
|
mcpBaseUrl: string
|
|
firebase: {
|
|
apiKey: string
|
|
authDomain: string
|
|
projectId: string
|
|
storageBucket?: string
|
|
messagingSenderId?: string
|
|
appId?: string
|
|
}
|
|
}
|
|
|
|
function getClineEnv(): Environment {
|
|
const _env = process?.env?.CLINE_ENVIRONMENT
|
|
if (_env && Object.values(Environment).includes(_env as Environment)) {
|
|
return _env as Environment
|
|
}
|
|
return Environment.production
|
|
}
|
|
|
|
// Config getter function to avoid storing all configs in memory
|
|
function getEnvironmentConfig(env: Environment): EnvironmentConfig {
|
|
switch (env) {
|
|
case Environment.staging:
|
|
return {
|
|
appBaseUrl: "https://staging-app.cline.bot",
|
|
apiBaseUrl: "https://core-api.staging.int.cline.bot",
|
|
mcpBaseUrl: "https://api.cline.bot/v1/mcp",
|
|
firebase: {
|
|
apiKey: "AIzaSyASSwkwX1kSO8vddjZkE5N19QU9cVQ0CIk",
|
|
authDomain: "cline-staging.firebaseapp.com",
|
|
projectId: "cline-staging",
|
|
storageBucket: "cline-staging.firebasestorage.app",
|
|
messagingSenderId: "853479478430",
|
|
appId: "1:853479478430:web:2de0dba1c63c3262d4578f",
|
|
},
|
|
}
|
|
case Environment.local:
|
|
return {
|
|
appBaseUrl: "http://localhost:3000",
|
|
apiBaseUrl: "http://localhost:7777",
|
|
mcpBaseUrl: "https://api.cline.bot/v1/mcp",
|
|
firebase: {
|
|
apiKey: "AIzaSyD8wtkd1I-EICuAg6xgAQpRdwYTvwxZG2w",
|
|
authDomain: "cline-preview.firebaseapp.com",
|
|
projectId: "cline-preview",
|
|
},
|
|
}
|
|
default:
|
|
return {
|
|
appBaseUrl: "https://app.cline.bot",
|
|
apiBaseUrl: "https://api.cline.bot",
|
|
mcpBaseUrl: "https://api.cline.bot/v1/mcp",
|
|
firebase: {
|
|
apiKey: "AIzaSyC5rx59Xt8UgwdU3PCfzUF7vCwmp9-K2vk",
|
|
authDomain: "cline-prod.firebaseapp.com",
|
|
projectId: "cline-prod",
|
|
storageBucket: "cline-prod.firebasestorage.app",
|
|
messagingSenderId: "941048379330",
|
|
appId: "1:941048379330:web:45058eedeefc5cdfcc485b",
|
|
},
|
|
}
|
|
}
|
|
}
|
|
|
|
// Get environment once at module load
|
|
const CLINE_ENVIRONMENT = getClineEnv()
|
|
const _configCache = getEnvironmentConfig(CLINE_ENVIRONMENT)
|
|
|
|
console.info("Cline environment:", CLINE_ENVIRONMENT)
|
|
|
|
export const clineEnvConfig = _configCache
|