gpt4 book ai didi

google-chrome - Grails/Chrome 错误 : resource interpreted as Font but transferred with MIME type application/octet-stream

转载 作者:行者123 更新时间:2023-12-02 15:33:56 25 4
gpt4 key购买 nike

如何在 Chrome 中设置 woff 字体的 mime 类型,就像 font-awesome bootstrap 库使用的那样?

最佳答案

创建 Grails custom mapper通过把下面的FontResourceMapper.groovy文件放入文件夹:grails-app/resourceMappers/
FontResourceMapper.groovy

import org.grails.plugin.resource.mapper.MapperPhase

class FontResourceMapper {

static phase = MapperPhase.ALTERNATEREPRESENTATION
static defaultIncludes = ["**/*.woff"]

def map(resource, config) {
// Changes "application/octet-stream" to correct MIME type to avoid browser warning
resource.requestProcessors << { req, resp ->
resp.setHeader("Content-Type", "application/font-woff")
}
}

}

改编自 halfbaked's solution .

关于google-chrome - Grails/Chrome 错误 : resource interpreted as Font but transferred with MIME type application/octet-stream,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14944029/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com