Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: storage preview in studio

Inian34a35239ceb1
diff --git a/studio/pages/api/storage/[ref]/buckets/[id]/objects/sign.ts b/studio/pages/api/storage/[ref]/buckets/[id]/objects/sign.ts
index 13383de212c..d235508ab84 100644
--- a/studio/pages/api/storage/[ref]/buckets/[id]/objects/sign.ts
+++ b/studio/pages/api/storage/[ref]/buckets/[id]/objects/sign.ts
@@ -2,7 +2,7 @@ import { createClient } from '@supabase/supabase-js'
import apiWrapper from 'lib/api/apiWrapper'
import { NextApiRequest, NextApiResponse } from 'next'
-const supabase = createClient(process.env.SUPABASE_PUBLIC_URL!, process.env.SUPABASE_SERVICE_KEY!)
+const supabase = createClient(process.env.SUPABASE_URL!, process.env.SUPABASE_SERVICE_KEY!)
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -27,5 +27,10 @@ const handlePost = async (req: NextApiRequest, res: NextApiResponse) => {
return res.status(400).json({ error: { message: error.message } })
}
+ // change the domain name to the SUPABASE_PUBLIC_URL since SUPABASE_URL is not accessible from the client
+ const signedUrl = new URL(data.signedUrl)
+ signedUrl.hostname = new URL(process.env.SUPABASE_PUBLIC_URL!).hostname
+ data.signedUrl = signedUrl.href
+
return res.status(200).json(data)
}