Deploy the backend to another domain
Hello, I'd like to know if it's possible to have the "backend" part of the bundle deployed to another domain than the one hosting the frontend part.
For example I'd like my frontend to be served at https://acme.com, and the backend at https://api.acme.com (server functions + api routes).
I'm asking this because of technical limitations on the target I'd like to deploy. 😄
9 Replies
genetic-orange•10mo ago
how would that work ? the initial page load needs the "backend part" for SSR
so maybe you just need a way to supply your hostname? should be trivial for API routes but for server functions this is not possible yet
correct-apricotOP•10mo ago
Sorry I wrote that without testing, so to be more precise, I want to deploy the
server/index.ts
part produced by the build
command (my target is deno
that's why it's a TypeScript file) on my "backend" (Supabase Edge Functions) and the other assets (script files, favicon...etc) on another domain (Supabase Storage)
as index.ts
is referencing assets, I need a way to set some kind of "asset hostname" or baseUrl for them.
so when the page loads through SSR, the scripts included in the page point to my bucketgenetic-orange•10mo ago
bucket?
correct-apricotOP•10mo ago
like a S3 bucket, on Supabase we have a storage service to store static assets
my goal being to deploy a TanStack start app fully on Supabase infrastructure 🤞
on one side we have Edge Functions (backend/compute), and on the other Storage (static assets)
genetic-orange•10mo ago
how are assets referenced currently? just relative ?
and which assets are those really? favicon you can set yourself
correct-apricotOP•10mo ago
By assets I mean everything under the public folder

correct-apricotOP•10mo ago
currently they're being referenced as if they are all hosted on the same domain as the
server/index.ts
part
so that would be something like <script src="/_build/assets/client-Dd5LmA5Q.js"></script>
for example
in my case what I want is something like: <script src="https://<supabase-project>/storage/objects/v1/_build/assets/client-Dd5LmA5Q.js"></script>
so https://<supabase-project>/storage/objects/v1/
would be my "assets baseUrl"genetic-orange•10mo ago
got it
@Sean Cassiere do you know if this can be configured already?
ambitious-aqua•10mo ago
Currently not that I'm aware of.
From what I know however, for this to work there'd need to be some code changes since the request origin for server functions would need to be changed since it'd be living elsewhere.
You'd need to search if such a thing is even possible with Nitro.