pagefind
pagefind copied to clipboard
Hosting with dotnet
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.
Thank you @Hugos68 ! I will get this on the website soon.
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