AndServer
AndServer copied to clipboard
低版本手机报错application/octet-stream
Failed to load module script: The server responded with a non-JavaScript MIME type of "application/octet-stream". Strict MIME type checking is enforced for module scripts per HTML spec
@Gitmingshao 加个HandlerInterceptor
@Interceptor
class LoggerInterceptor : HandlerInterceptor {
companion object {
private const val TAG = "WebLogger"
}
override fun onIntercept(
request: HttpRequest,
respons: HttpResponse,
handler: RequestHandler,
): Boolean {
val httpPath = request.path
val method = request.method
val valueMap = request.parameter
RLog.v(TAG, "Path:$httpPath, Method:${method.value()}, Param:${Gson().toJson(valueMap)}")
if (httpPath.endsWith(".css")) {
respons.setHeader("Content-Type", "text/css; charset=UTF-8")
} else if (httpPath.endsWith(".js")) {
respons.setHeader("Content-Type", "application/javascript; charset=UTF-8")
}
return false
}
}
我的2.1.10加上了,还是提示错误 Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "application/octet-stream". Strict MIME type checking is enforced for module scripts per HTML spec.
@Gitmingshao 加个HandlerInterceptor
@interceptor class LoggerInterceptor : HandlerInterceptor { companion object { private const val TAG = "WebLogger" } override fun onIntercept( request: HttpRequest, respons: HttpResponse, handler: RequestHandler, ): Boolean { val httpPath = request.path val method = request.method val valueMap = request.parameter RLog.v(TAG, "Path:$httpPath, Method:${method.value()}, Param:${Gson().toJson(valueMap)}") if (httpPath.endsWith(".css")) { respons.setHeader("Content-Type", "text/css; charset=UTF-8") } else if (httpPath.endsWith(".js")) { respons.setHeader("Content-Type", "application/javascript; charset=UTF-8") } return false } }
totally works. many thanks