par*_*sit 6 javascript go vue.js
有什么方法可以覆盖 FileServer 中使用的内容类型吗?我有用 golang 编写的简单 REST 服务器,现在我想在 Vue 中添加一些“前端”。
Html/js 文件从文件夹中提供/static/,几乎一切正常......
几乎,除了 Vue 文件。
我的/static/服务由:
fs := http.FileServer(http.Dir("./static/"))
router.PathPrefix("/static/").Handler(http.StripPrefix("/static/", fs))
Run Code Online (Sandbox Code Playgroud)
所有*.vue文件都提供Content-Type: text/plain; charset=utf-8,并且所有浏览器都会抛出错误:
Failed to load module script:
Expected a JavaScript module script but the server responded with a MIME type of "text/plain".
Strict MIME type checking is enforced for module scripts per HTML spec.
Run Code Online (Sandbox Code Playgroud)
如何覆盖这个Content-type?也许像Handler.extension_mappython 中的东西?
我试过:
Failed to load module script:
Expected a JavaScript module script but the server responded with a MIME type of "text/plain".
Strict MIME type checking is enforced for module scripts per HTML spec.
Run Code Online (Sandbox Code Playgroud)
它本身工作得很好,但显然被文件服务器忽略了。
或者,还有什么方法可以解决这个问题?
PS 是的,我看到: http.FileServer 响应错误的 mime“Content-Type”, 但对我的情况没有帮助。
| 归档时间: |
|
| 查看次数: |
1391 次 |
| 最近记录: |