diff --git a/src/hooks.server.ts b/src/hooks.server.ts index f3f87e04..e07cc016 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -14,7 +14,6 @@ export async function handle({ event, resolve }) { // annoying hack to fix lemmy's CORS if (event.url.pathname.startsWith('/cors')) { // cut off the 1st slash (empty), and remove the /cors - event.request.headers.delete('origin') event.request.headers.delete('host') @@ -58,7 +57,6 @@ export async function handle({ event, resolve }) { ) } } catch (error) { - console.error(error) return new Response( JSON.stringify({ message: 'the proxy failed to fetch from server', diff --git a/vercel.json b/vercel.json new file mode 100644 index 00000000..90bc7584 --- /dev/null +++ b/vercel.json @@ -0,0 +1,22 @@ +{ + "headers": [ + { + "source": "/cors/(.*)", + "headers": [ + { "key": "Access-Control-Allow-Credentials", "value": "true" }, + + { "key": "Access-Control-Allow-Origin", "value": "*" }, + + { + "key": "Access-Control-Allow-Methods", + "value": "GET,OPTIONS,PATCH,DELETE,POST,PUT" + }, + + { + "key": "Access-Control-Allow-Headers", + "value": "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version" + } + ] + } + ] +}