赞
踩
进入到localhost:8080
后页面空白,打开控制台可以发现报错:
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/plain"
调试FastAPI应用查看发现Server返回的header中content-type确实为text/plain
,奇怪的是一模一样的代码Linux中就正常运行,遂手动添加MIME类型到Python的mimetypes库,在./backend/main.py
中添加以下代码即可正常运行:
import mimetypes
mimetypes.add_type('application/javascript', '.js')
问题解决。
相关博客:关于vite build后访问报错:Expected a JavaScript module script but the server responded with a MIME type of “
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。