display text files in browser
This commit is contained in:
parent
d5f705ae72
commit
0288bb6e02
|
@ -92,7 +92,12 @@ async function get(request,host,path) {
|
||||||
const headers = new Headers()
|
const headers = new Headers()
|
||||||
dest_file.writeHttpMetadata(headers)
|
dest_file.writeHttpMetadata(headers)
|
||||||
headers.set("etag", dest_file.httpEtag)
|
headers.set("etag", dest_file.httpEtag)
|
||||||
|
if (mime.startsWith("text/")) {
|
||||||
|
headers.set("content-type", "text/plain")
|
||||||
|
headers.set("x-content-type", mime)
|
||||||
|
} else {
|
||||||
headers.set("content-type", mime)
|
headers.set("content-type", mime)
|
||||||
|
}
|
||||||
return new Response(dest_file.body, { headers, } )
|
return new Response(dest_file.body, { headers, } )
|
||||||
}
|
}
|
||||||
const dest = await KV.get(path)
|
const dest = await KV.get(path)
|
||||||
|
|
Loading…
Reference in a new issue