Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

🐛 Let the API host's /v1 reach the API instead of the not-found page (#3284)

Luke Vella37ddf5b5f4b5
diff --git a/apps/web/next.config.ts b/apps/web/next.config.ts
index a59938f34..31fa3c19d 100644
--- a/apps/web/next.config.ts
+++ b/apps/web/next.config.ts
@@ -56,7 +56,8 @@ const nextConfig: NextConfig = {
// host later without inheriting them.
async rewrites() {
if (!process.env.API_BASE_URL) return [];
- const host = new URL(process.env.API_BASE_URL).host;
+ // Next compares the request host without its port, so use hostname.
+ const host = new URL(process.env.API_BASE_URL).hostname;
return [
{
source: "/v1/:path*",
diff --git a/apps/web/src/proxy.ts b/apps/web/src/proxy.ts
index 03e395fb3..bc1c6e443 100644
--- a/apps/web/src/proxy.ts
+++ b/apps/web/src/proxy.ts
@@ -74,6 +74,10 @@ export const proxy = async (req: NextRequest) => {
return res;
};
+// `/v1` is the public API on the API host: next.config rewrites it to
+// `/api/v1`, and that rewrite only runs when this proxy does not claim the
+// request first. Without the exclusion the locale rewrite sends it to the
+// not-found route.
export const config = {
- matcher: ["/((?!api|_next/static|_next/image|static|.*\\.).*)"],
+ matcher: ["/((?!api|v1|_next/static|_next/image|static|.*\\.).*)"],
};