This repository was archived by the owner on Feb 13, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
This repository was archived by the owner on Feb 13, 2026. It is now read-only.
Incorrect Content-Type text/plain for javascript in zip-archive #19440
Copy link
Copy link
Closed
Description
Incorrect Content-Type: text/plain when requesting assets from *.zip archive (javascript and css files).
I tried using minio s3 as static site hosting (html, js, css, images).
I upload site.zip, then open https://***/bucket/site.zip/index.html.
(In front of minio is installed nginx with configured proxy_pass to :9000 port and additional X-Minio-Extract header).
Thehtml-page opens fine. But all assets are returned with header Content-Type: text/plain instead of:
text/css and text/javascript.
As a result, there is the errors in the browser:
Refused to apply style from 'https://***/bucket/site.zip/src/style.css' because its MIME type ('text/plain') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
# and:
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.
So far I've only found a single solution at the Nginx level:
####
## (!) Fixed an error: Refused to apply style from 'https://***/bucket/site.zip/src/style.css' because
## its MIME type ('text/plain') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
####
map $uri $assets_content_type {
# if $http_host contains the word staging
"~.+\.js$" "text/javascript";
"~.+\.css$" "text/css";
default "text/plain";
}
server {
# ....
location ~.+\.(js|css)$ {
## My: Use Indexing for extract Zip archives (Zip Extract). Example: /site.zip/index.html
proxy_set_header X-Minio-Extract true;
## Proxy to :9000
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 300;
# Default is HTTP/1, keepalive is only enabled in HTTP/1.1
proxy_http_version 1.1;
proxy_set_header Connection "";
chunked_transfer_encoding off;
# This uses the upstream directive definition to load balance
proxy_pass https://minio_s3;
#proxy_hide_header X-Content-Type-Options;
proxy_hide_header Content-Type;
add_header Content-Type "$assets_content_type";
}
}
## ...This seems to have solved the problem. But maybe there is a more elegant solution.. Thank you 🤝
Reactions are currently unavailable