From 12cd9f4fe6ecc0c0ec5150d12fe3d034b9d68f2e Mon Sep 17 00:00:00 2001 From: Jack Merrill Date: Wed, 19 Jul 2023 21:26:14 -0500 Subject: [PATCH] fix: remove redirect, use proxied data --- next.config.js | 9 --------- src/app/.well-known/matrix/[slug]/route.ts | 13 +++++++++++++ 2 files changed, 13 insertions(+), 9 deletions(-) create mode 100644 src/app/.well-known/matrix/[slug]/route.ts diff --git a/next.config.js b/next.config.js index 2e34c74..3dcc307 100644 --- a/next.config.js +++ b/next.config.js @@ -3,15 +3,6 @@ const nextConfig = { images: { domains: ["cdn.sanity.io"], }, - async redirects() { - return [ - { - source: "/.well-known/matrix/:slug*", - destination: "https://matrix.jackmerrill.com/.well-known/matrix/:slug*", - permanent: true, - }, - ]; - }, }; module.exports = nextConfig; diff --git a/src/app/.well-known/matrix/[slug]/route.ts b/src/app/.well-known/matrix/[slug]/route.ts new file mode 100644 index 0000000..af6b48e --- /dev/null +++ b/src/app/.well-known/matrix/[slug]/route.ts @@ -0,0 +1,13 @@ +export async function GET( + request: Request, + { params }: { params: { slug: string } } +) { + const slug = params.slug; // 'server', 'client', or 'support' for Matrix + + const response = await fetch( + `https://matrix.jackmerrill.com/.well-known/matrix/${slug}` + ); + const headers = { "content-type": "application/json" }; + const body = JSON.stringify(await response.json()); + return new Response(body, { headers }); +}