Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
I am confused why an axios call from my render application works
Post Flair (click to view more posts with a particular flair)
Post Body

Hi.

I have a pretty simple express app that I was building locally.

I took this express app and deployed it to render. The front end javascript has an axios call, I am surprised that it works / I would like to understand why / how it works.

express was running locally, and the client side js has a call

//axios.get("http://localhost:3000/results")
axios.get(axiosURL   "/results")

This was originally hard coded, but then replaced by a matching environment variable on my local deploy.

What I had expected was that if I deploy to render, the client side javascript will not work {since it will query localhost/results}. I don't have a listener up on my mac while testing render's deploy. Somehow, this call still worked.

I had been planning to pass environment variable to the client side script. Changing these env variables once I get the url for the render deploy. I am confused why this worked, on render, when the above url calling for localhost {since... my current localhost does listen on 3000}

Does render somehow, see the variables for localhost and replace it with its own hostname? Inspecting chrome dev tools I see that axios did infact call : myurl/results however I absolutely did not expect this. Its as if render took the client side js code, looked for localhost - and replaced localhost with the resolved app url post deploy.

This is very cool... however un-expected. Are there any other nifty things render might be doing / does this behavior cause un-intended consequences elsewhere?

Thanks!

Author
Account Strength
100%
Account Age
7 years
Verified Email
Yes
Verified Flair
No
Total Karma
14,671
Link Karma
181
Comment Karma
14,490
Profile updated: 3 days ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
4 months ago