mirror of
https://github.com/modrinth/code.git
synced 2026-08-25 00:55:25 +00:00
Chyz/improve preview workers (#6802)
* fix: branch url in comment * fix: use sub not small * de-hardcode siteUrl * simplify request hook * nuxt server plugin? * pull directly from worker + 2 tables * debug * undebug * single preview worker? * use pr number instead of name because pr names tend to be long + can be changed * prepr --------- Co-authored-by: Calum H. (IMB11) <contact@cal.engineer> Co-authored-by: Prospector <6166773+Prospector@users.noreply.github.com>
This commit is contained in:
co-authored by
Calum H.
Prospector
parent
56ff97ee6f
commit
dce20777ef
@@ -364,11 +364,7 @@ function getFeatureFlagOverrides() {
|
||||
|
||||
function getDomain() {
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
// @ts-ignore
|
||||
if (process.env.CF_PAGES_URL || globalThis.CF_PAGES_URL) {
|
||||
// @ts-ignore
|
||||
return process.env.CF_PAGES_URL ?? globalThis.CF_PAGES_URL
|
||||
} else if (process.env.HEROKU_APP_NAME) {
|
||||
if (process.env.HEROKU_APP_NAME) {
|
||||
return `https://${process.env.HEROKU_APP_NAME}.herokuapp.com`
|
||||
} else if (process.env.VERCEL_URL) {
|
||||
return `https://${process.env.VERCEL_URL}`
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
const mod = 'cloudflare:workers'
|
||||
const { env } = await import(/* @vite-ignore */ mod)
|
||||
const cfEnv = env as any
|
||||
const config = useRuntimeConfig(event)
|
||||
|
||||
if (cfEnv.CF_PAGES_URL) config.public.siteUrl = cfEnv.CF_PAGES_URL
|
||||
if (cfEnv.BROWSER_BASE_URL) config.public.apiBaseUrl = cfEnv.BROWSER_BASE_URL
|
||||
if (cfEnv.BASE_URL) config.apiBaseUrl = cfEnv.BASE_URL
|
||||
if (cfEnv.PYRO_BASE_URL) {
|
||||
config.public.pyroBaseUrl = cfEnv.PYRO_BASE_URL
|
||||
config.pyroBaseUrl = cfEnv.PYRO_BASE_URL
|
||||
}
|
||||
if (cfEnv.STRIPE_PUBLISHABLE_KEY)
|
||||
config.public.stripePublishableKey = cfEnv.STRIPE_PUBLISHABLE_KEY
|
||||
} catch {
|
||||
/* empty */
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user