Files
Raúl Barroso f5f897a29b feat(functions): inject env var function slug (#49617)
## 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?

Feature (self-hosted Edge Functions)

## What is the current behavior?

The self-hosted Edge Functions router
(`docker/volumes/functions/main/index.ts`) doesn't tell a function which
slug a request resolved to. As a result, `@supabase/server`'s
`withOAuthProtectedResource` can't derive its canonical resource URL and
falls back to reconstructing it from the request path against the
internal `api-gw` origin, so the advertised OAuth Protected Resource is
/wrong for self-hosted deployments.

## What is the new behavior?

`main/index.ts` now injects `SUPABASE_FUNCTION_SLUG: service_name` per
request (after the `Deno.env.toObject()` snapshot, so nothing in the
container env can shadow it).

Combined with the operator's `SUPABASE_PUBLIC_URL`, the advertised
resource is the correct external
`{SUPABASE_PUBLIC_URL}/functions/v1/{slug}`, not the internal
`http://api-gw:8000`.

Verified on the docker stack: the slug is injected per-function, the
resource origin resolves to `SUPABASE_PUBLIC_URL`, and the `401`
`www-authenticate` carries the right `resource_metadata`.

## Additional context

Fixes AI-1128

Companion to `@supabase/server` [PR
#117](https://github.com/supabase/server/pull/117) and the [CLI slug
injection](https://github.com/supabase/cli/pull/6345)

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

## Summary by CodeRabbit

* **Bug Fixes**
* Edge workers now receive the correct function slug in their runtime
environment, improving per-function request handling.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-08-28 12:32:30 +02:00
..

License Ask DeepWiki

Self-Hosted Supabase with Docker

This is the official Docker Compose setup for self-hosted Supabase. It provides a complete stack with all Supabase services running locally or on your infrastructure.

Getting Started

Follow the detailed setup guide in our documentation: Self-Hosting with Docker

The guide covers:

  • Prerequisites (Git and Docker)
  • Initial setup and configuration
  • Securing your installation
  • Accessing services
  • Updating your instance

What's Included

This Docker Compose configuration includes the following services:

  • Studio - A dashboard for managing your self-hosted Supabase project
  • Envoy - API gateway (default; Kong is available as an optional override via sh run.sh config add kong)
  • Auth - JWT-based authentication API for user sign-ups, logins, and session management
  • PostgREST - Web server that turns your PostgreSQL database directly into a RESTful API
  • Realtime - Elixir server that listens to PostgreSQL database changes and broadcasts them over websockets
  • Storage - RESTful API for managing files in S3, with Postgres handling permissions
  • imgproxy - Fast and secure image processing server
  • postgres-meta - RESTful API for managing Postgres (fetch tables, add roles, run queries)
  • PostgreSQL - Object-relational database with over 30 years of active development
  • Edge Runtime - Web server based on Deno runtime for running JavaScript, TypeScript, and WASM services
  • Logflare - Log management and event analytics platform
  • Vector - High-performance observability data pipeline for logs
  • Supavisor - Supabase's Postgres connection pooler

Documentation

Updates

Back up your database, then:

sh update.sh --dry-run   # optional preview
sh update.sh
sh run.sh pull && sh run.sh recreate

See the update guide for conflicts, breaking changes, pinning a release, and older installs without .supabase-version.

Community & Support

For troubleshooting common issues, see:

Self-hosted Supabase is community-supported. Get help and connect with other users:

  • Discord - Real-time chat and community support
  • Reddit - Official Supabase subreddit

Share your self-hosting experience:

Important Notes

Security

⚠️ The default configuration is not secure for production use.

Before deploying to production, you must:

  • Update all default passwords and secrets in the .env file
  • Review and update CORS settings
  • Consider setting up a secure proxy in front of self-hosted Supabase
  • Review and adjust network security configuration (ACLs, etc.)
  • Set up proper backup procedures

See the main installation guide and the how-tos in the documentation.

License

This repository is licensed under the Apache 2.0 License. See the main Supabase repository for details.