Skip to content

Regression using paths in supabaseUrl since 2.49.5 #1421

@etzelc

Description

@etzelc

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

Starting from PR #1417 (released with 2.49.5), the way Supabase client URLs are constructed has changed. Previously, endpoint URLs (e.g., auth, realtime) were generated by concatenating the base Supabase URL with the corresponding paths. The new implementation uses the URL constructor instead.

However, because the endpoint paths begin with a leading /, any path component included in the base Supabase URL is discarded. This means base URLs that include a path no longer behave as expected.

To Reproduce

This constructs the URLs in a similar way like it is done in the current code

const realtimeUrl = "/realtime/v1";
const supabaseUrlWithoutTrailingSlash = "https://example.com/path/to/supabase"; // Worked in versions ≤ 2.49.4
const constructorResultUrl1 = new URL(realtimeUrl, supabaseUrlWithoutTrailingSlash);
// ==>  https://example.com/realtime/v1

const supabaseUrlWithTrailingSlash = "https://example.com/path/to/supabase/";
const constructorResultUrl2 = new URL(realtimeUrl, supabaseUrlWithTrailingSlash);
// ==>  https://example.com/realtime/v1

Expected behavior

The base Supabase URL should preserve its path component until the last forward-slash when constructing service URLs, as it did in versions up to and including 2.49.4.

Possible fix:

Remove leading slash from endpoint path and do NOT strip the trailing slash from the supabaseUrl.

const realtimeUrlNew = "realtime/v1";
const supabaseUrlWithTrailingSlash = "https://example.com/path/to/supabase/";
const constructorResultUrl3 = new URL(realtimeUrlNew, supabaseUrlWithTrailingSlash);
// ==> https://example.com/path/to/supabase/realtime/v1

System information

  • Version of supabase-js: 2.49.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions