Devashish
Devashish

Reputation: 1290

Create react app multiple ports for same app

My React app (made on CRA) is running on localhost://3000. Now, for some testing purposes, I want to be able to run the SAME app on multiple ports. I am doing this to simulate multiple devices (so that each device has different instance of localStorage and indexeddb). How can I achieve this so that I can run the same app on, say, ports 3000, 4000, 5000 and 6000?

Upvotes: 0

Views: 1428

Answers (1)

Michael Nelles
Michael Nelles

Reputation: 5992

You can use the npm library called concurrently. Found here: https://www.npmjs.com/package/concurrently

here is a snippet of your npm run commands so you can run either or both

  "scripts": {
    "start": "node server.js",
    "server": "nodemon server.js --ignore client",
    "client": "npm start --prefix client",
    "dev": "concurrently \"npm run server\" \"npm run client\""
  },

Upvotes: 1

Related Questions