Create react app build, build interface report 404?

1. The building environment I use is that what create react app, wants to do is to request Douban api, but because it is cross-domain, proxy, is configured and in order to deploy to github page, package.json is also configured with the corresponding homepage.
local runtime, but an error is reported when build is deployed online:

Failed to load resource: the server responded with a status of 404 ()

my package.json:

{
  "name": "imovie",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.4.2",
    "react-dom": "^16.4.2",
    "react-scripts": "1.1.4",
    "antd-mobile": "^2.2.2"
  },
  "scripts": {
    "start": "react-app-rewired start",
    "build": "react-app-rewired build",
    "test": "react-app-rewired test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "devDependencies": {
    "axios": "^0.18.0",
    "babel-plugin-import": "^1.8.0",
    "css-loader": "^1.0.0",
    "less": "^3.8.1",
    "less-loader": "^4.1.0",
    "qs": "^6.5.2",
    "react-app-rewired": "^1.5.2",
    "style-loader": "^0.22.0"
  },
  "proxy": "https://api.douban.com",
  "homepage": "https://lawlietze.github.io/testServer"
}

part of my request:

    componentDidMount(){
        let _This = this;
        axios.get("/v2/movie/in_theaters")
        .then(function (response) {
            console.log(response);
            _This.setState({ result: response.data.subjects });
        })
        .catch(function (error) {
        console.log(error);
        });
    }

the environmental background of the problems and what methods you have tried

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?


just check to see if the console has requested an interface to the real Douban


when developing, you can configure proxy to proxy, and after packaging, you also need to configure proxy proxy, such as using nginx .

Menu