Binita DhakalandAlaister Young cd34776be1 fix(studio): honor MAINTENANCE_MODE in the TanStack runtime (#48616)
## What kind of change does this PR introduce?

Bug fix.

## What is the current behavior?

Fixes #48559 (diagnosed by @ayaangazali)

The TanStack Start runtime never applies maintenance mode.

`matchRedirect` in `apps/studio/redirects.shared.ts` takes a
`maintenanceMode`
flag, and both other consumers wire it from the environment:

- `apps/studio/next.config.ts` — `process.env.MAINTENANCE_MODE ===
'true'`
- `apps/studio/vercel.ts` — same

The TanStack call site in `apps/studio/routes/__root.tsx` passed only
`pathname`, `search`, `isPlatform` and `hash`, so `maintenanceMode` fell
back
to its `= false` default. With `MAINTENANCE_MODE=true` on a TanStack
deploy
that produced two wrong behaviors:

1. No path redirected to `/maintenance` — the app served normally during
   maintenance.
2. Because the flag read false, the "not in maintenance" branch still
applied
and sent `/maintenance` → `/`, making `routes/maintenance.tsx`
unreachable.

Mainly affects self-hosted / Node-server TanStack deploys; the platform
deploy
is covered by the Vercel edge layer, which does wire the flag.

## What is the new behavior?

The TanStack runtime honors `MAINTENANCE_MODE` the same way the Next
runtime
and the edge config do.

**Design note.** The issue asked whether this needs a new `NEXT_PUBLIC_`
variable or server-side plumbing, since both would change deployment
configuration for self-hosters. Neither is needed. `MAINTENANCE_MODE` is
already a *build-time* variable in both existing consumers — Next bakes
`redirects()` into `routes-manifest.json` during `next build`, and
`vercel.ts`
reads it while emitting `vercel.json`. Toggling maintenance has always
required
a rebuild, never just a server restart. And `vite.config.ts` isn't bound
by
Next's "only `NEXT_PUBLIC_`" rule: it controls `define` directly, and
already
re-exposes unprefixed `VERCEL_*` vars the same way. So the existing
unprefixed
variable is inlined at build time, giving exact parity with **no new env
var
and no config change for self-hosters**.

Three changes:

1. `vite.config.ts` — inline `process.env.MAINTENANCE_MODE` into the
bundle.
Falls back to `''` rather than being left undefined, so the browser
bundle
never ends up with a bare `process.env` reference (the failure mode the
file
   already guards against for the Sentry vars).
2. `routes/__root.tsx` — read it into `IS_MAINTENANCE_MODE` and pass it
to
   `matchRedirect`.
3. `redirects.shared.test.ts` — 4 tests for the maintenance branches of
   `matchRedirect`, which had no coverage at all.

`turbo.jsonc` already lists `MAINTENANCE_MODE` under the build task's
`env`, so
cache invalidation is correct for the Vite build too — no change needed.
No
README or docs change either, since the env contract is unchanged.

## Additional context

Verified end-to-end, not just by unit test.

**Browser repro** — built SPA served via `scripts/serve.js`, driven in
headless
Chromium:

| `MAINTENANCE_MODE=true` | lands on | |
| --- | --- | --- |
| `/project/default` | `/maintenance` | fixes behavior 1 |
| `/` | `/maintenance` | |
| `/maintenance` | `/maintenance` | fixes behavior 2 |

The maintenance page renders real content ("Under Maintenance — We are
currently improving our services…"), so the route is genuinely
reachable.

| control, var unset | lands on | |
| --- | --- | --- |
| `/project/default` | `/project/default` | normal routing intact |
| `/` | `/project/default` | root redirect intact |
| `/maintenance` | `/project/default` | correctly bounces away |

**Bundle inspection** — the flag compiles to a literal `true` with the
variable
set and `false` without it, confirming the define reaches the client.

**Shell prerender** — checked explicitly, since the maintenance-on rule
is a
catch-all. Builds with `MAINTENANCE_MODE=true` prerender the SPA shell
and pass
the post-build smoke test; the prerenderer crawls `/` and the root
`beforeLoad`
redirect does not fire during shell generation, so no guard is required.

**Checks** — 20 unit tests pass, typecheck 8/8, ESLint ratchet passes,
Prettier
clean.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
  - Added maintenance-mode routing for unavailable pages.
  - Preserves query parameters and URL fragments during redirects.
- Allows access to maintenance and image paths while maintenance mode is
active.
- Automatically returns visitors to the home page when maintenance mode
is disabled.
  - Maintenance behavior is controlled by the deployment configuration.

- **Tests**
- Added coverage for maintenance-mode redirects, URL preservation, and
exceptions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-09-01 06:32:18 +00:00
2026-08-24 10:06:36 -06:00
2025-06-17 11:08:46 +02:00
2024-01-10 13:34:41 +01:00
…

Supabase

Supabase is the Postgres development platform. We're building the features of Firebase using enterprise-grade open source tools.

  • Hosted Postgres Database. Docs
  • Authentication and Authorization. Docs
  • Auto-generated APIs.
  • Functions.
    • Database Functions. Docs
    • Edge Functions Docs
  • File Storage. Docs
  • AI + Vector/Embeddings Toolkit. Docs
  • Dashboard

Supabase Dashboard

Watch "releases" of this repo to get notified of major updates.

Watch this repo

Documentation

For full documentation, visit supabase.com/docs

To see how to Contribute, visit Getting Started

Community & Support

  • Community Forum. Best for: help with building, discussion about database best practices.
  • GitHub Issues. Best for: bugs and errors you encounter using Supabase.
  • Email Support. Best for: problems with your database or infrastructure.
  • Discord. Best for: sharing your applications and hanging out with the community.

How it works

Supabase is a combination of open source tools. We’re building the features of Firebase using enterprise-grade, open source products. If the tools and communities exist, with an MIT, Apache 2, or equivalent open license, we will use and support that tool. If the tool doesn't exist, we build and open source it ourselves. Supabase is not a 1-to-1 mapping of Firebase. Our aim is to give developers a Firebase-like developer experience using open source tools.

Architecture

Supabase is a hosted platform. You can sign up and start using Supabase without installing anything. You can also self-host and develop locally.

Architecture

  • Postgres is an object-relational database system with over 30 years of active development that has earned it a strong reputation for reliability, feature robustness, and performance.
  • Realtime is an Elixir server that allows you to listen to PostgreSQL inserts, updates, and deletes using websockets. Realtime polls Postgres' built-in replication functionality for database changes, converts changes to JSON, then broadcasts the JSON over websockets to authorized clients.
  • PostgREST is a web server that turns your PostgreSQL database directly into a RESTful API.
  • GoTrue is a JWT-based authentication API that simplifies user sign-ups, logins, and session management in your applications.
  • Storage a RESTful API for managing files in S3, with Postgres handling permissions.
  • pg_graphql a PostgreSQL extension that exposes a GraphQL API.
  • postgres-meta is a RESTful API for managing your Postgres, allowing you to fetch tables, add roles, and run queries, etc.
  • Envoy is a cloud-native, high-performance edge and service proxy.

Client libraries

Our approach for client libraries is modular. Each sub-library is a standalone implementation for a single external system. This is one of the ways we support existing tools.

Language Client Feature-Clients (bundled in Supabase client)
Supabase PostgREST GoTrue Realtime Storage Functions
⚡️ Official ⚡️
JavaScript (TypeScript) supabase-js postgrest-js auth-js realtime-js storage-js functions-js
Flutter supabase-flutter postgrest-dart gotrue-dart realtime-dart storage-dart functions-dart
Swift supabase-swift postgrest-swift auth-swift realtime-swift storage-swift functions-swift
Python supabase-py postgrest-py gotrue-py realtime-py storage-py functions-py
💚 Community 💚
C# supabase-csharp postgrest-csharp gotrue-csharp realtime-csharp storage-csharp functions-csharp
Go - postgrest-go gotrue-go - storage-go functions-go
Java - - gotrue-java - storage-java -
Kotlin supabase-kt postgrest-kt auth-kt realtime-kt storage-kt functions-kt
Ruby supabase-rb postgrest-rb - - - -
Rust - postgrest-rs - - - -
Godot Engine (GDScript) supabase-gdscript - - - - -

Badges

Made with Supabase

[![Made with Supabase](https://supabase.com/badge-made-with-supabase.svg)](https://supabase.com)
<a href="https://supabase.com">
  <img
    width="168"
    height="30"
    src="https://supabase.com/badge-made-with-supabase.svg"
    alt="Made with Supabase"
  />
</a>

Made with Supabase (dark)

[![Made with Supabase](https://supabase.com/badge-made-with-supabase-dark.svg)](https://supabase.com)
<a href="https://supabase.com">
  <img
    width="168"
    height="30"
    src="https://supabase.com/badge-made-with-supabase-dark.svg"
    alt="Made with Supabase"
  />
</a>

Translations

Languages
TypeScript 59.3%
MDX 21.6%
JavaScript 17.8%
CSS 0.6%
Shell 0.4%
Other 0.2%