If I want my pages app (Vite + React)

If I want my pages app (Vite + React) deployed to domain.com/route but then I also have pages functions eg functions/connect-to-db.js what route will that server function be accessible at?
8 Replies
agathorpt
agathorpt14mo ago
I'm assuming it will be on domain.com/connect-to-db
Isaac McFadyen
Isaac McFadyen14mo ago
It depends on how you are deploying the Vite app to a path. If the path is done in Vite internally (i.e. the Pages project is just deployed on the whole domain and then Vite is set to only use /route) then yes, the path will be domain.com/connect-to-db
Nikil
NikilOP14mo ago
can you clarify? so how do I call my pages function in the frontend part of the vite app? Just do a fetch request to that domain.com/connect-to-db URL? the Pages project is NOT being deployed to the whole domain at least, I don't want to
Isaac McFadyen
Isaac McFadyen14mo ago
How are you restricting it to the path?
Nikil
NikilOP14mo ago
I was planning to just set the trigger to a specific route can I not do that?
Isaac McFadyen
Isaac McFadyen14mo ago
I don't think you can with Pages, no.
Nikil
NikilOP14mo ago
oh but I guess I can redirect using a worker to a page? so I could redirect inventxyz.com/team to team.inventxyz.com ?
agathorpt
agathorpt14mo ago
functions are deployed from the root of the project and their routing is folder based so you can only setup the functions starting from the domain/subdomain defined for the cloudflare page. You can indeed add a worker for that redirection as long as you own the domain
Want results from more Discord servers?
Add your server