2

Firstly, I'm sorry for my English grammar...

Okay, so I already run my react on the website, but when I type the site URL in the address bar, I need to even put :3000 after the URL. If it's running on-site, I don't want to put the port on the URL. Can anyone help me on how to run react without the port number in the deployed site?

it should look like this... example.site.com not like example.site.com:3000

If you need any details to tell me in the comments. THANKS IN ADVANCE!!!

Amal K
  • 4,359
  • 2
  • 22
  • 44
  • 1
    You may have to remove the 3000 (hard coded string). Also, by default port 80 is used, you may find more details over here: Remove port from Node js website url – Agent K Jun 19 '21 at 03:22
  • thanks ive gotten more ideas of what i got to do but problem is i dont use node its only a reactjs –  Jun 19 '21 at 03:49
  • 1
    Just to help you in short, you should consider watching this video: https://www.youtube.com/watch?v=uRDkRjpg48I – Agent K Jun 19 '21 at 04:01
  • im currently following the video... you should consider commenting on answer section not on comments section because if it works ill give you a check mark and upvote :) –  Jun 19 '21 at 04:44
  • Please watch and confirm, then I will add it as an answer otherwise people downvote unnecessarily. – Agent K Jun 19 '21 at 06:44
  • when i run npm run build i had error it was about mozjpeg/vendor/cjpeg write EPIPE –  Jun 19 '21 at 06:50
  • You should try running this command: sudo apt-get install libpng16-dev – Agent K Jun 19 '21 at 07:03
  • ok but is sudo for mac? because im using m1 macos –  Jun 19 '21 at 07:06
  • sudo: apt-get: command not found –  Jun 19 '21 at 07:08

1 Answers1

0

Did you run npm run build and take the "build" folder that is generated and copied that folder to your server? If you did it, its not a React problem/configuration, it's an server configuration, and depends of the server your are using. Nginx is a popular one. If you don't run npm run build and you put all your project code on the server, and you are running that code with npm start then you are doing it your deployment in the wrong way.

  • 1
    i actually didnt run npm build and im runnning my site with npm start..... im new to this so pls dont be angry... ok so after i do npm build what do i do? btw thanks for fast reply to my post :) also i forgot to mention, if i put example.com it shows text because i have index.html... do i remove index.html or do something? –  Jun 19 '21 at 03:40
  • Don't worried, there is a starting point always. Where are you deploying your code? To a self managing server? – Adrián Fernández Martínez Jun 19 '21 at 04:17
  • You can use this links: https://www.pluralsight.com/guides/deploy-a-react-app-on-a-server If you are using create-react-app maybe this guide will help you: https://create-react-app.dev/docs/deployment/ – Adrián Fernández Martínez Jun 19 '21 at 04:26
  • thanks for you kindness... so im deplying my code from vesta and filezilla... illl try the links you gave me aswell –  Jun 19 '21 at 04:35