pagefind icon indicating copy to clipboard operation
pagefind copied to clipboard

Hosting with dotnet

Open Hugos68 opened this issue 1 year ago • 2 comments

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.

Hugos68 avatar Dec 11 '23 14:12 Hugos68

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

bglw avatar Jan 06 '24 09:01 bglw

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

Karlstens avatar Jun 18 '24 04:06 Karlstens