feature request: Supabase Management integration available to local supabase as well
Current issue
- run supabase locally:
npx supabase start - create a job using the Supabase Management SDK on local.
- the following error occurs and the integration is not created.
Error: Failed to run query: Unauthorized (401): invalid signature
at SupabaseManagementAPI.createResponseError_fn (/workspaces/nextjs-supabase-triggerdev-test/node_modules/supabase-management-js/dist/index.js:1102:10)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SupabaseManagementAPI.runQuery (/workspaces/nextjs-supabase-triggerdev-test/node_modules/supabase-management-js/dist/index.js:626:13)
at async executeTask (/workspaces/nextjs-supabase-triggerdev-test/node_modules/@trigger.dev/sdk/dist/index.js:930:24)
at async ioConnection.<computed> [as runQuery] (/workspaces/nextjs-supabase-triggerdev-test/node_modules/@trigger.dev/sdk/dist/index.js:506:18)
at async Object.register (/workspaces/nextjs-supabase-triggerdev-test/node_modules/@trigger.dev/supabase/dist/index.js:540:28)
at async ExternalSource.register (/workspaces/nextjs-supabase-triggerdev-test/node_modules/@trigger.dev/sdk/dist/index.js:1810:21)
at async Object.run (/workspaces/nextjs-supabase-triggerdev-test/node_modules/@trigger.dev/sdk/dist/index.js:1497:25)
at async #executeJob (/workspaces/nextjs-supabase-triggerdev-test/node_modules/@trigger.dev/sdk/dist/index.js:1600:20)
at async TriggerClient.handleRequest (/workspaces/nextjs-supabase-triggerdev-test/node_modules/@trigger.dev/sdk/dist/index.js:1312:25)
at async handler (/workspaces/nextjs-supabase-triggerdev-test/node_modules/@trigger.dev/nextjs/dist/index.js:32:22)
Cause
The supabase-management-js used internally assumes the use of the cloud version. Therefore, it is not possible to issue a webhook to a locally hosted supabase.
Furthermore, there is no API to enable webhooks in local supabase.
Suggestion for improvement
case 1
- when creating a Supabase Management class, the connection string to the supabase-db can be passed as an argument.
- the argument of 1. is given, execute the query of
createTriggerQuerydirectly.
case 2
case 1 is preferable because it can be automated, but if SQL execution is not preferred, this option is also available.
- when creating a Supabase Management class, you can pass an option to omit automatic webhook create as an argument.
- the argument of 1. is given, instead of executed the query of
createTriggerQuery, output it to the log (to be executed manually by the user)
Any progress with this? i have the same issue and cannot test it locally
I manage some progress, at least I get to have it well deployed but when I do some insert in the db it does not work:
new Job(client, {
id: 'my-job',
name: 'My job',
version: '0.0.1',
trigger: db.onInserted({
schema: 'public',
table: 'users',
}),
run: async (payload, io, ctx) => {
console.log('added users')
io.logger.info('Add customers')
io.logger.info('payload', payload)
io.logger.info('ctx', ctx)
},
})
Self-hosted Supabase does not use the Management API (ref).
It does however use Postgres Meta, but I'm not sure if that would be able to fill the gap.
The best would be if Supabase added support for the Management API in their self-hosted version.
I am also interested in this. I could get the payload to hit trigger.dev but without being able to hash the the webhook's secret key in the header I couldn't do anything with the payload. I just can see it and the trigger fails.
I was thinking of implementing Auth.js from Supabase in my local instance and seeing if that has any luck.