react-app-rewired customise default start url

929 views Asked by At

I have installed react-app-rewired. In the package.json I have set

"scripts": {
  "start": "react-app-rewired start --scripts-version react-scripts",
}

When I run

npm start

It opens a browser window on localhost:3000 I would like to open it to a specific URL:port that I have set in my hosts file. This will allow my local front end app to contact a remote API without throwing a CORS issue.

1

There are 1 answers

1
test30 On

this is webpack-dev-server related

module.exports = {
  //...
  devServer: {
    open: ['/my-page'],
  },
};

https://webpack.js.org/configuration/dev-server/#devserveropen

// config-overrides.js

module.exports = () => ({
  devServer: (c) => {
    return () => ({open: ['/newer-url']});
  }
});