i am a beginner (i don’t even know how to ask the question correctly) and i try creating my first clone website as a project with the help of youtube tutorial and everything went well but i have one issue with the url…so when the person that i watch run his code it shows as http://127.0.0.1:5000 (which i know is the localhost address) but when i run it keep showing http://localhost:5000 so can anyone tell me how do i set mine to show like this http://127.0.0.1:5000
i want my url to show http://127.0.0.1:5000 instead of http://localhost:5000
Edit: there’s a lot of answers thaks to everyone but there seem to be some confusion and i don’t really know how to answer them (i’m sorry i will become better) so i’ll just put a picture i it…also i am using npmenter image description here
4
Answers
It’s simple the person you are watching has there own HTTP WEB SERVER and that’s why there project is running at Localhost address , and if you also want to do the same thing you would need to program the server yourself or use a http server software for running your website on Localhost address.
I hope this helps you!
Open your package.json file in your react project and find
scripts
section in it. Under thescripts
section you need to modify thestart
section value toreact-scripts start --host 127.0.0.1
. Finally, your package.jsonscripts
section will look like the below with your other configuration:Make sure to save your changes and proceed with
npm start
. Now your client-side application will be available to access viahttp://127.0.0.1:5000
Your question is not well defined unless you state how you run your web app.
If Create React App is used, as assumed by Selaka Nanayakkara’s answer, you can also use a
HOST
environment variable.Presumption
Its kinda hard to understand what your trying to imply, but from what i’m seeing you’re wanting to show your local host-name IP (
127.0.0.1
in this case) rather thanlocalhost
in the search barSolution
Based on the above –
# 1 Create a
.env.local
file in the main directory (not in any subfolders)# 2
Within that file have the following
# 3
Run yarn or npm once more and it should work!