CloudCannon / pagefind

Static low-bandwidth search at scale
https://pagefind.app
MIT License
3.21k stars 96 forks source link

Hosting with dotnet #527

Open Hugos68 opened 6 months ago

Hugos68 commented 6 months ago

When hosting via dotnet and using the app.UseStaticFiles() you require to add:

var provider = new FileExtensionContentTypeProvider();
provider.Mappings[".pagefind"] = "application/wasm";
provider.Mappings[".pf_meta"] = "application/wasm";
provider.Mappings[".pf_index"] = "application/wasm";
provider.Mappings[".pf_fragment"] = "application/wasm";
app.UseStaticFiles(new StaticFileOptions
{
    ContentTypeProvider = provider
});

Otherwise dotnet will recognize those files as "unknown" and therefor not serve them and return a 404 instead.

Do with this information whatever you think is appropiate but wanted to document it somewhere for future visitors.

bglw commented 5 months ago

Thank you @Hugos68 ! I will get this on the website soon.

Karlstens commented 2 weeks ago

Can confirm, I also experienced an issue with the current version of PageFind. The PageFind search for my VitePress project hosted via CPanel worked out of the box, whilst the same build hosted on Windows IIS needed MIME types added as "application/wasm" (application/octet-stream also worked... but changed to wasm after reading this post ) for the following extensions;

.pagefind .pf_meta .pf_index .pf_fragment