# How To Get The Server URL?

**URL:** <https://forum.freecodecamp.org/t/how-to-get-the-server-url/623482>\
**Category:** Curriculum Help\
**Tags:** backend\
**Created:** [July 18, 2023, 1:32am UTC](https://forum.freecodecamp.org/t/how-to-get-the-server-url/623482 "2023-07-18T01:32:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![josephylee](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/josephylee/32/288090_2.png) [@josephylee](https://forum.freecodecamp.org/u/josephylee)\
**Post date:** [July 18, 2023, 1:32am UTC](https://forum.freecodecamp.org/t/how-to-get-the-server-url/623482/1 "2023-07-18T01:32:15Z")

</div>

Hello,

This may seem like a basic question, but I’ve been having trouble understanding how to do this.

I am pretty comfortable using `fetch()` and `GET` requests on the client side, but I am kinda lost as to how to create a server `URL` for clients to send requests to.

```auto
const host = 'localhost';
const port = 8000; 

```

So a local client can send network requests to `http://localhost:8000`, but what about remote requests? I feel like I would need to create a server `URL` for remote clients to use as a destination for `fetch()` and `XMLHttpRequest()` requests.

Once I deploy my `server.js` file to a provider, will they give me a `URL` that I can then assign to the `host` variable, and would that be enough to allow remote clients to access my `server.js` script using network requests?

I would super appreciate if someone could ELI5. Thank you!

---

<div class="post-metadata">

**Author:** ![GerrardAfk](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/gerrardafk/32/325654_2.png) [@GerrardAfk](https://forum.freecodecamp.org/u/GerrardAfk)\
**Post date:** [July 18, 2023, 2:53am UTC](https://forum.freecodecamp.org/t/how-to-get-the-server-url/623482/2 "2023-07-18T02:53:28Z")

</div>

of course, when you deploy your server to a provider such as Heroku, Render, etc… . they will provide a Url that you will provide to your client so that they can use to communicate to your server like `fetch('https://exampleurl.com')`

> [This is an article about deploying node.js server with Render for free](https://www.freecodecamp.org/news/how-to-deploy-nodejs-application-with-render/)

I believe I understood your question and answered accordingly,  
regards

---

<div class="post-metadata">

**Author:** ![josephylee](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/josephylee/32/288090_2.png) [@josephylee](https://forum.freecodecamp.org/u/josephylee)\
**Post date:** [July 18, 2023, 3:02am UTC](https://forum.freecodecamp.org/t/how-to-get-the-server-url/623482/3 "2023-07-18T03:02:05Z")

</div>

@GerrardAfk

Thank you very much.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 7, 2025, 11:47am UTC](https://forum.freecodecamp.org/t/how-to-get-the-server-url/623482/4 "2025-01-07T11:47:56Z")

</div>

Closed on January 7, 2025, 11:47am UTC


