'How to remove port number from URL when running npm start?

I'm working on a create-react-app and I want to remove the port number from the URL that gets created when I run npm start in my api. Right now, my start scripts contains this:

"start": "json-server --host https://my-json-server.typicode.com/vbrambila2/1RM" 

This is the URL I want my api tp run on. But when I run npm start, it gets initiated as:

https://my-json-server.typicode.com/vbrambila2/1RM:3000

I also get this error in my terminal:

  Resources
  http://https://my-json-server.typicode.com/vbrambila2/1RM:3000/movements

  Home
  http://https://my-json-server.typicode.com/vbrambila2/1RM:3000

Some error occurred Error: getaddrinfo ENOTFOUND https://my-json-server.typicode.com/vbrambila2/1RM
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:69:26) {
  errno: -3008,
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'https://my-json-server.typicode.com/vbrambila2/1RM'

Does anyone know how I can get it to start as just the URL I provided and not add the :3000?



Solution 1:[1]

Any HTTP URL without the port specified implicitly specifies port 80 (HTTP) or port 443 (HTTPS). Eg.

http://example.com => http://example.com:80

https://example.com => https://example.com:443

To avoid typing in the port number, you should serve your content on port 443 (since you are using HTTPS). You haven't told us what framework you are using to host your server, but typically the CLI options for setting ports is either '-p' or '--port', although you should read the documentation page for your framework first.

Edit:

Based on your tags, I'm inferring that you're using json-server in which case, adding -p 443 to your start command should set the port appropriately.

Solution 2:[2]

On your .env file you must add HTTPS=true and PORT=443

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Not Dylan Burns
Solution 2 NicoIama