我正在尝试添加一个域名到我的react应用程序中,但是当我添加它时,我得到了一个404响应。它在github页面托管中运行良好,但当我添加域名时,我得到了错误。不确定我的package.json文件中是否遗漏了什么?请帮帮忙,我已经被困了好长时间了。
这是我的package.json
{
"name": "casahogar",
"homepage": "https://castillojuan1000.github.com/casaHogar",
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.9.1",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"axios": "^0.20.0",
"cors": "^2.8.5",
"emailjs-com": "^2.6.3",
"express": "^4.17.1",
"feather-icons": "^4.28.0",
"framer-motion": "^1.11.1",
"gh-pages": "^3.1.0",
"react": "^16.13.1",
"react-axios": "^2.0.3",
"react-dom": "^16.13.1",
"react-modal": "^3.11.2",
"react-router-dom": "^5.2.0",
"react-scripts": "^3.4.3",
"react-scroll": "^1.8.1",
"react-slick": "^0.26.1",
"react-stripe-checkout": "^2.6.3",
"react-toastify": "^6.0.9",
"slick-carousel": "^1.8.1",
"smoothscroll-polyfill": "^0.4.4",
"stripe": "^8.108.0",
"styled-components": "^5.1.1",
"tailwindcss": "^1.4.6",
"twin.macro": "^1.4.1",
"use-in-view": "^1.0.15",
"uuid": "^8.3.1",
"uuidv4": "^6.2.4"
},
"proxy": "http://localhost:4242",
"scripts": {
"server": "nodemon src/Server.js",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"nodemon": "^2.0.4"
}
}
这是我在namecheap中的设置:

发布于 2020-11-04 19:49:24
您的网站正在尝试从错误的URL获取静态资产(JS和CSS)。它在https://www.casahogarscj.com/casaHogar/static/...上请求它们,而Github在https://www.casahogarscj.com/static/...上为它们提供服务(没有casaHogar)。
要解决此问题,您需要在package.json中将homepage值更改为https://www.casahogarscj.com/,然后重建您的网站。
https://stackoverflow.com/questions/64673629
复制相似问题