The cross-domain setting of the react project created by create-react-app is invalid after using github pages after build

Set this in

package.json , use fetch request, no problem during development

"proxy": {
  "/api": {
    "target": "https://h5.ele.me",
    "changeOrigin": true,
    "pathRewrite": {
      "^/api": "/"
    }
  }
}
// 
fetch(`api/restapi/shopping/v3/hot_search_words?latitude=${a.latitude}&longitude=${a.longitude}`)

deployment using github pages after build resulted in an error in the request. The paragraph in the red box below should be the above target, so the request failed. How to modify this situation? if not, is there another way to preview the project

clipboard.png


create a new nginx configuration file gihtubpage.conf

server {
    listen 80 default_server;
    listen [::]:80 ipv6only=on default_server;
    location /api/ {
        proxy_pass https://h5.ele.me/;
    }
}
Menu