FleekHQ / ic-proxy

HTTPS Proxy to Internet Computer
4 stars 0 forks source link

Custom mime types #1

Open lastmjs opened 3 years ago

lastmjs commented 3 years ago

Many of my apps load TypeScript files over the network directly. TypeScript files end in .ts, and the MIME type for .ts is not application/javascript. Thus, my apps are breaking using the ic-proxy service worker.

It would be great to have the ability to add custom MIME types for different file extensions. Looking through the service worker JavaScript file, the mime package is being used. It is not easy to add MIME types to that library, so an extra-library method would probably have to be used.

I'm also not sure the best place to provide the custom MIME types, perhaps simply as a JSON file in the root directory of an application deployed to the IC through Fleek. The JSON file could simply map extensions to MIME types, and the service worker could request this file and give it precedence over the mime package.

lastmjs commented 3 years ago

Actually, probably a better more general solution is to allow the user to set their own custom headers per path. This would allow setting any HTTP headers on any path, and would also solve this MIME type issue. Perhaps a simple JSON file mapping a path regex to an array with custom headers in it would work?

studna commented 3 years ago

Hi @lastmjs ! Sorry I didn't notice this issue earlier. I assume you already switched to native IC gateway that supports fetching assets via HTTP, right? Actually that's a reason why we're about to deprecate this custom proxy.