forked from stackblitz/bolt.new
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'stackblitz-labs:main' into ACT_BoltDYI_BUGFIX_DATATAB
- Loading branch information
Showing
19 changed files
with
263 additions
and
774 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,41 @@ | ||
import type { LoaderFunction } from '@remix-run/cloudflare'; | ||
import { providerBaseUrlEnvKeys } from '~/utils/constants'; | ||
import { LLMManager } from '~/lib/modules/llm/manager'; | ||
import { getApiKeysFromCookie } from '~/lib/api/cookies'; | ||
|
||
export const loader: LoaderFunction = async ({ context, request }) => { | ||
const url = new URL(request.url); | ||
const provider = url.searchParams.get('provider'); | ||
|
||
if (!provider || !providerBaseUrlEnvKeys[provider].apiTokenKey) { | ||
if (!provider) { | ||
return Response.json({ isSet: false }); | ||
} | ||
|
||
const envVarName = providerBaseUrlEnvKeys[provider].apiTokenKey; | ||
const isSet = !!(process.env[envVarName] || (context?.cloudflare?.env as Record<string, any>)?.[envVarName]); | ||
const llmManager = LLMManager.getInstance(context?.cloudflare?.env as any); | ||
const providerInstance = llmManager.getProvider(provider); | ||
|
||
if (!providerInstance || !providerInstance.config.apiTokenKey) { | ||
return Response.json({ isSet: false }); | ||
} | ||
|
||
const envVarName = providerInstance.config.apiTokenKey; | ||
|
||
// Get API keys from cookie | ||
const cookieHeader = request.headers.get('Cookie'); | ||
const apiKeys = getApiKeysFromCookie(cookieHeader); | ||
|
||
/* | ||
* Check API key in order of precedence: | ||
* 1. Client-side API keys (from cookies) | ||
* 2. Server environment variables (from Cloudflare env) | ||
* 3. Process environment variables (from .env.local) | ||
* 4. LLMManager environment variables | ||
*/ | ||
const isSet = !!( | ||
apiKeys?.[provider] || | ||
(context?.cloudflare?.env as Record<string, any>)?.[envVarName] || | ||
process.env[envVarName] || | ||
llmManager.env[envVarName] | ||
); | ||
|
||
return Response.json({ isSet }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,8 @@ | ||
import type { LoaderFunctionArgs } from '@remix-run/node'; | ||
import { json, type LoaderFunctionArgs } from '@remix-run/cloudflare'; | ||
|
||
export const loader = async ({ request: _request }: LoaderFunctionArgs) => { | ||
// Return a simple 200 OK response with some basic health information | ||
return new Response( | ||
JSON.stringify({ | ||
status: 'healthy', | ||
timestamp: new Date().toISOString(), | ||
uptime: process.uptime(), | ||
}), | ||
{ | ||
status: 200, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}, | ||
); | ||
return json({ | ||
status: 'healthy', | ||
timestamp: new Date().toISOString(), | ||
}); | ||
}; |
Oops, something went wrong.