score:1

Accepted answer

in your root project add a file called .env, inside the file enter the path you want:

public_url=/v2/

this should fix your problem.

if you want to modify webpack.config.js in a react project created with npx create-react-app i suggest you to install craco https://www.npmjs.com/package/@craco/craco .

after the installation you need to replace some lines of your package.json

from

...
  "scripts": {
    "start": "react-script start",
    "build": "react-script build",
    "test": "react-script test",
    "eject": "react-script eject"
  },
...

to

...
  "scripts": {
    "start": "craco start",
    "build": "craco build",
    "test": "craco test",
    "eject": "craco eject"
  },
...

after that, in your root project add a file called craco.config.js

inside the file add the following code

module.exports = {
    configure: {
      output: {
        publicpath: '/v2/'
      }
    }
  }
}

Related Query

More Query from same tag