Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to load resource: the server responded with a status of 404 (Not Found) 开发环境是正常的,打包后浏览器打开出问题 #1140

Closed
bioinformatica opened this issue Nov 1, 2022 · 3 comments

Comments

@bioinformatica
Copy link

bioinformatica commented Nov 1, 2022

umirc.js

publicPath: '/',
history: {
type: 'hash',
},

@bioinformatica
Copy link
Author

bioinformatica commented Nov 1, 2022

在src文件夹添加 app.js文件

import { message } from 'antd'

export const dva = {
config: {
onError(e) {
e.preventDefault();
if (e.message) {
message.error(e.message)
} else {
/* eslint-disable */
console.error(e)
}
},
},
};

使用 live-server ./dist ,
浏览器访问http://127.0.0.1:8080/#/ 显示404 Not Found的页面,
Live reload enabled.
GET http://127.0.0.1:8080/api/v1/user 404 (Not Found)

@bioinformatica bioinformatica changed the title 为什么我打包之后部署,打开浏览器一直loading Failed to load resource: the server responded with a status of 404 (Not Found) 开发环境是正常的,打包后浏览器打开出问题 Nov 1, 2022
@bioinformatica
Copy link
Author

#1064 (comment) 相同的界面 404

@superlbr
Copy link
Collaborator

superlbr commented Nov 2, 2022

打开浏览器调试,可以看到静态文件走了一个域名

  1. 需要在.umirc文件里,删掉或修改publicPath配置
  2. /api/v1/user,需要请求后端的接口。调试的时候走的是mock

@superlbr superlbr closed this as completed Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants