PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, July 13, 2022

[FIXED] How to serve react app on server with sub-directory homepage on an existing domain?

 July 13, 2022     build, reactjs, web-deployment     No comments   

Issue

I am new to webdev. I want to deploy a react-app on our lab's server. i want other lab members to access this app with https://ourlab.org:PORT_NUM/myApp

On the lab server by sshing to it: under my home directory, i have this myApp folder. I give package.json this "homepage":"https://ourlab.org/myApp" field and then run npm run build, and then run npx serve -s build

it gives me

| Serving! │

│ - Local: http://localhost:5000 │

│ - On Your Network: http://159.89.xxx.xxx:5000 |

I expect I could access the app at url https://ourlab.org:5000/myApp on my local computer. But my browser does not get response.

BTW could someone please explain how this "homepage" works with more details?


Solution

when you run serve, you are serving the app from your local computer. If you want to serve the app from your lab-server find the document root on that server, create there a directory "myApp" and copy the content of the build directory from your computer into that directory on your lab server.

The build directory is the result of running ´npm run build´ assuming you have created your app with create-react-app.



Answered By - Michael
Answer Checked By - Senaida (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing