mirror of
https://github.com/teoxoy/factorio-blueprint-editor.git
synced 2024-11-28 08:39:10 +02:00
add support for deploying on cloudflare pages
This commit is contained in:
parent
a3c35d4c4a
commit
879aeedad8
3
.gitignore
vendored
3
.gitignore
vendored
@ -3,7 +3,8 @@ dist
|
|||||||
packages/website/tools/.fusebox
|
packages/website/tools/.fusebox
|
||||||
packages/backend/data
|
packages/backend/data
|
||||||
packages/backend/target
|
packages/backend/target
|
||||||
packages/exporter/data
|
packages/exporter/data/*
|
||||||
|
!packages/exporter/data/output
|
||||||
packages/exporter/target
|
packages/exporter/target
|
||||||
packages/lua-runtime/tools/emsdk
|
packages/lua-runtime/tools/emsdk
|
||||||
packages/lua-runtime/tools/cache
|
packages/lua-runtime/tools/cache
|
||||||
|
26
functions/corsproxy.js
Normal file
26
functions/corsproxy.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
export async function onRequest({ request }) {
|
||||||
|
const url = new URL(request.url)
|
||||||
|
let apiUrl = url.searchParams.get('url')
|
||||||
|
|
||||||
|
if (apiUrl == null) {
|
||||||
|
return new Response()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rewrite request to point to API url. This also makes the request mutable
|
||||||
|
// so we can add the correct Origin header to make the API server think
|
||||||
|
// that this request isn't cross-site.
|
||||||
|
const proxyRequest = new Request(apiUrl, request)
|
||||||
|
proxyRequest.headers.set('Origin', new URL(apiUrl).origin)
|
||||||
|
let response = await fetch(proxyRequest, { redirect: 'follow' })
|
||||||
|
|
||||||
|
// Recreate the response so we can modify the headers
|
||||||
|
response = new Response(response.body, response)
|
||||||
|
|
||||||
|
// Set CORS headers
|
||||||
|
response.headers.set('Access-Control-Allow-Origin', url.origin)
|
||||||
|
|
||||||
|
// Append to/Add Vary header so browser will cache response correctly
|
||||||
|
response.headers.append('Vary', 'Origin')
|
||||||
|
|
||||||
|
return response
|
||||||
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user