Files
supabase/apps/studio
Andrew ValleteauandClaude Fable 5.1 6fab3bd789 fix(studio): keep sharp out of the self-hosted standalone build (#50658)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Bug fix (self-hosted Studio image packaging).

## What is the current behavior?

Since the Next 16.3.5 bump, the self-hosted `next build` (`output:
'standalone'`) traces Next's optional `sharp` dependency into
`.next/standalone`. Next 16.3.5 upgraded `@vercel/nft`
(vercel/next.js#93979), so tracing now follows `module-sync` export
conditions, and Next only excludes sharp from the trace when it detects
Vercel.

Effects:

- The self-hosted standalone output carries the `sharp` and `@img/*`
native binaries, roughly 10 to 20 percent of the image.
- The slim-services Studio image fails: it loads every `.node` file
eagerly, and sharp's binary segfaults on linux/amd64 without the
matching libvips shared library.

`apps/studio` does not depend on `sharp` directly. The last Studio image
without sharp in the trace was `2026.09.14`.

## What is the new behavior?

Single-file change to `apps/studio/next.config.ts`. When
`NEXT_PUBLIC_IS_PLATFORM` is not `'true'`:

- `images.unoptimized: true`, so `next/image` renders plain `<img>` and
the server 404s `/_next/image` before sharp is ever loaded. This matches
what the TanStack build already does via `compat/next/image.tsx`.
- `outputFileTracingExcludes` drops `**/node_modules/sharp/**` and
`**/node_modules/@img/**` from the standalone trace.

Hosted Studio is unchanged: `unoptimized` stays `false`, the exclude key
is omitted, and image optimization keeps running on Vercel. Self-hosted
CSP is `frame-ancestors 'none'` only, so loading remote avatars directly
instead of through `/_next/image` does not hit a CSP rule.

Also hoists the existing `isPlatform` const from `redirects()` to module
scope.

**Why the globs start with `../../`.** Studio builds with Turbopack,
which resolves `outputFileTracingExcludes` relative to the app
directory. A plain `**/node_modules/sharp/**` becomes
`apps/studio/**/node_modules/sharp/**` and never matches the pnpm store
hoisted to the monorepo root. Each leading `../` moves the glob root up
one level (`relativize_glob` in Next's `crates/next-core/src/util.rs`),
so `../../` anchors the pattern at the repo root. The webpack path
applies the same globs unprefixed for the server trace, so this is
Turbopack-specific.

## Additional context

Considered and rejected: a Next.js issue. Next intentionally ships sharp
for self-hosted `next start` image optimization and intentionally
excludes it only on Vercel. Opting out per app is the supported path.

Test plan:

- CI: typecheck, lint, Prettier, Studio unit tests, Studio Docker Build.
- Verified on this PR with a temporary step in the Studio Docker Build
workflow that ran `find` inside the production image for
`node_modules/sharp*` and `node_modules/@img*` files. It failed on the
first commit (globs rooted at `apps/studio`, image still contained
`@img/colour`) and passed once the globs were anchored at the repo root.
The step was removed before merge.
- Hosted preview should still serve optimized images from
`/_next/image`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01SZHcgqB2qNqCvWsFJ9Qvo8

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

## Summary by CodeRabbit

* **Refactor**
* Improved configuration handling for platform and self-hosted
deployments.
* Self-hosted builds now avoid bundling unnecessary image-processing
binaries, while platform deployments retain image optimization support.
  * Clarified configuration comments.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-21 18:45:15 +02:00
..

Supabase Studio

A dashboard for managing your self-hosted Supabase project, and used on our hosted platform. Built with:

What's included

Studio is designed to work with existing deployments - either the local hosted, docker setup, or our CLI. It is not intended for managing the deployment and administration of projects - that's out of scope.

As such, the features exposed on Studio for existing deployments are limited to those which manage your database:

  • Table & SQL editors
    • Saved queries are unavailable
  • Database management
    • Policies, roles, extensions, replication
  • API documentation

Managing Project Settings

Project settings are managed outside of the Dashboard. If you use docker compose, you should manage the settings in your docker-compose file. If you're deploying Supabase to your own cloud, you should store your secrets and env vars in a vault or secrets manager.

How to contribute?

  • Branch from master and name your branches with the following structure
    • {type}/{branch_name}
      • Type: chore | fix | feature
      • The branch name is arbitrary — just make sure it summarizes the work.
  • When you send a PR to master, it will automatically tag members of the frontend team for review.
  • Review the main contributing guide to help test your feature before sending a PR.
  • The Dashboard is under active development. You should run git pull frequently to make sure you're up to date.

Developer Quickstart

Note

Supabase internal use: To develop on Studio locally with the backend services, see the instructions in the internal infrastructure repo.

# You'll need to be on Node v22
# in /studio

## For external contributors
pnpm install # install dependencies
pnpm run dev # start dev server

## For internal contributors
## First clone the private supabase/platform repo and follow instructions for setting up mise
mise studio  # Run from supabase/platform alongside `mise infra`

## For all
pnpm run test # run tests
pnpm run test -- --watch # run tests in watch mode

Running within a self-hosted environment

Follow the self-hosting guide to get started.

cd ..
cd docker
docker compose -f docker-compose.yml -f ./dev/docker-compose.dev.yml up

Once you've got that set up, update .env in the studio folder with the corresponding values.

POSTGRES_PASSWORD=
SUPABASE_ANON_KEY=
SUPABASE_SERVICE_KEY=

Then run the following commands to install dependencies and start the dashboard.

npm install
npm run dev

If you would like to configure different defaults for "Default Organization" and "Default Project", you will need to update the .env in the studio folder with the corresponding values.

DEFAULT_ORGANIZATION_NAME=
DEFAULT_PROJECT_NAME=