mirror of
https://github.com/supabase/supabase.git
synced 2026-10-13 21:29:08 +03:00
fix(studio): build worker URLs on the project domain and correct the region
Workers answer at <project>/workers/v1/<name>, not a shared workers.supabase.co host, and the alpha region is us-west-2.
This commit is contained in:
1 parent
537ca65e59
commit
9fd08667df
2 files changed
+31
-3
No files matched your search
@@ -1,12 +1,21 @@
|
||||
import type { Worker, WorkerBuildState } from './Workers.types'
|
||||
|
||||
// Locked to one region at alpha, so nothing in the UI lets you change it.
|
||||
export const WORKERS_REGION = 'us-west-1'
|
||||
export const WORKERS_REGION = 'us-west-2'
|
||||
export const WORKERS_REGION_LABEL = 'US West (Oregon)'
|
||||
export const WORKERS_REGION_SHORT = 'US West'
|
||||
|
||||
// Private workers share this URL shape; access is enforced by the gateway, not the path.
|
||||
export const workerGatewayUrl = (name: string) => `https://workers.supabase.co/v1/${name}`
|
||||
// Workers answer on the project's own domain, alongside /functions/v1, and the api-gateway keeps
|
||||
// the route dark for projects outside the alpha allow-list.
|
||||
export const workerUrl = ({
|
||||
endpoint,
|
||||
protocol = 'https',
|
||||
name,
|
||||
}: {
|
||||
endpoint: string | undefined
|
||||
protocol?: string
|
||||
name: string
|
||||
}) => (endpoint ? `${protocol}://${endpoint}/workers/v1/${name}` : undefined)
|
||||
|
||||
export const LISTENING_PORT = 8080
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { workerUrl } from './Workers.constants'
|
||||
import type { Worker } from './Workers.types'
|
||||
import {
|
||||
filterWorkers,
|
||||
@@ -137,3 +138,21 @@ describe('isWorkersAccessDenied', () => {
|
||||
expect(isWorkersAccessDenied(null)).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('workerUrl', () => {
|
||||
it('answers on the project domain alongside /functions/v1', () => {
|
||||
expect(workerUrl({ endpoint: 'abcdefgh.supabase.co', name: 'embed' })).toBe(
|
||||
'https://abcdefgh.supabase.co/workers/v1/embed'
|
||||
)
|
||||
})
|
||||
|
||||
it('honours a non-https protocol', () => {
|
||||
expect(workerUrl({ endpoint: 'localhost:8000', protocol: 'http', name: 'embed' })).toBe(
|
||||
'http://localhost:8000/workers/v1/embed'
|
||||
)
|
||||
})
|
||||
|
||||
it('has no url until the project settings resolve', () => {
|
||||
expect(workerUrl({ endpoint: undefined, name: 'embed' })).toBeUndefined()
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user