我使用 vite 作为我的 React 应用程序的构建工具,并使用 golang 作为后端。
我构建了用于生产的应用程序并将该应用程序托管在我的 http 服务器上。
我的目录结构:
server
|- dist
| | index.html
| |- assets
| | index.js
| | index.css
| main.go
托管我的文件的代码看起来像(在 main.go 中)
fs := http.FileServer(http.Dir("./dist"))
http.Handle("/", fs)
在 index.html 中
<script type="module" crossorigin src="/assets/index.fd457ca0.js"></script>
<link rel="stylesheet" href="/assets/index.bdcfd918.css">
该代码确实发送了正确的文件,但标头错误。
智慧大石
相关分类