How to Write Fetch URLs when working on a local test?

I’m working on a project using React and Express. What is the best practice for coding in the fetch URLs that my react project will use when those same URLs will change in production?

i.e., they’re localhost:8000/getdata (or whatever) right now, but they’ll be someapp.com/getdata when it goes to production?

I’m sure there’s some kind of best practice for this, but I don’t even know what it’s called to google it.

Thank you!

1 Like

They aren’t currently–I’m running a react instance and a separate Express one. Most of the tutorials I’ve seen indicate that express has a hard time running anything but a npm build version a react page. I would LIKE to have the react page be served up as the static page from express when I’m done, though.

EDIT: slight change for clarity

1 Like

Hi there,

Wonderful, that’s just the kind of info I’m looking for (the separation of back and front end, when it’s appropriate, etc.). But the link didn’t come through–can you please resend?

Thank you!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.