mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-19 00:02:03 +00:00
adapt static adapter to cloudflare
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
v17.9.0
|
||||
v16.15.0
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import preprocess from 'svelte-preprocess'
|
||||
import adapter from '@sveltejs/adapter-static'
|
||||
|
||||
|
||||
/** @type {import('@sveltejs/kit').Config} */
|
||||
const config = {
|
||||
// Consult https://github.com/sveltejs/svelte-preprocess
|
||||
@@ -13,13 +12,15 @@ const config = {
|
||||
],
|
||||
|
||||
kit: {
|
||||
adapter: process.env.CLOUDFLARE ? staticAdapter({ pages: 'build', assets: 'build', fallback: 'index.html' }) : adapter({
|
||||
// default options are shown
|
||||
pages: 'build',
|
||||
assets: 'build',
|
||||
fallback: '200.html'
|
||||
}),
|
||||
prerender: { entries: [] },
|
||||
adapter: process.env.CLOUDFLARE
|
||||
? adapter({ pages: 'build', assets: 'build', fallback: 'index.html', precompress: false })
|
||||
: adapter({
|
||||
// default options are shown
|
||||
pages: 'build',
|
||||
assets: 'build',
|
||||
fallback: '200.html'
|
||||
}),
|
||||
prerender: { entries: [] }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//this is purely for cloudflare pages redirection purposes
|
||||
|
||||
export async function onRequest(context: EventContext<unknown, string, unknown>) {
|
||||
export async function onRequest(context) {
|
||||
// Contents of context object
|
||||
const {
|
||||
request, // same as existing Worker API
|
||||
@@ -11,9 +11,15 @@ export async function onRequest(context: EventContext<unknown, string, unknown>)
|
||||
data, // arbitrary space for passing data between middlewares
|
||||
} = context
|
||||
|
||||
const url = new URL(request.url)
|
||||
url.hostname = "app.windmill.dev"
|
||||
const res = await fetch(url.toString(), { method: request.method, body: request.body, headers: request.headers, redirect: 'manual' })
|
||||
res.headers.set('set-cookie', res.headers.get('set-cookie')?.replace('Domain=windmill.dev;', '') ?? '')
|
||||
return res
|
||||
try {
|
||||
const url = new URL(request.url)
|
||||
url.hostname = "app.windmill.dev"
|
||||
const res = await fetch(url.toString(), { method: request.method, body: request.body, headers: request.headers, redirect: 'manual' })
|
||||
const newResponse = new Response(res.body, res);
|
||||
newResponse.headers.set('set-cookie', newResponse.headers.get('set-cookie')?.replace('Domain=windmill.dev;', '') ?? '')
|
||||
return newResponse
|
||||
} catch (e) {
|
||||
return new Response(e.message, { status: 500 })
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user