#How would I get my backend server's url into my frontend?

13 messages · Page 1 of 1 (latest)

naive rivet
#

Hi. Sorry for the noob question.

I've currently got a project with a flask service serving as a backend, and a NextJS service as a frontend. I need some way to get the flask service's url into the environment of the nextjs one. After running through the docs, I tried setting NEXT_PUBLIC_API_URL = ${{flask.RAILWAY_STATIC_URL}}, but that comes up empty in the actual application. How would I go about this?

Cheers!

cobalt finchBOT
#

Project ID: 981f1af8-b6cc-4902-afe6-ca3eca8425e5

naive rivet
#

981f1af8-b6cc-4902-afe6-ca3eca8425e5

naive rivet
blazing nebula
naive rivet
#

do you know how I'd set one of those shared variables to be the deploy url of one of the sites?

blazing nebula
#

Why do you need to reference it, actually? You can just use the value of the URL (NEXT_PUBLIC_API_URL=https://your.flask.backend.up.railway.app)

naive rivet
#

yep, that's what I'm doing now.

#

I assumed there would be some better solution

#

but seems like hardcoding it is the way to go

blazing nebula
#

Hardcoding is the better solution for this, IMO. There's no need to complicate it unless your URL is dynamic (e.g. different deployments for preview/staging branches)

drowsy plover
#

just like to point out that those variables are not shareable between services, they are specific to only one service by design