.well-known folder

System Information
  • Strapi Version: 4.2.2
  • Operating System: Windows/Linux
  • Database: SQLite/MySQL
  • Node Version: 16.0
  • NPM Version: 6.14.17
  • Yarn Version:

Hi all,

I’m trying to include files in a path /.well-known/

I figured since the “public” folder corresponds to / that I could pop a .well-known folder in there, put my files in it and job done. Unfortunately, i get 404 errors when I navigate to /.well-known/. Any other subfolder name (other than .well-known) I try in /public works fine. e.g. /test/ Can anyone shed any light on what is happening and how I would solve it?



I am getting the same issue. Did you find a solution to this ?
Thanks in Advanced

This is because Strapi does not expose dot files, as stated in the docs.

I solved this by adding a custom middleware that exposes the .well-known folder.

 *  wellknown.ts
 *  place this file under src/middlewares/wellKnown.ts
import { Strapi } from "@strapi/strapi";
import koaStatic from "koa-static";

export default (config, { strapi }: { strapi: Strapi }) => {
      method: "GET",
      path: "/.well-known/(.*)",
      handler: koaStatic(strapi.dirs.static.public, {
        maxage: config.maxage,
        defer: true,
        hidden: true,
      config: { auth: false },

Then add the this line as last line to your config/middlewares.ts file:

export default [
  // ... your configured middlewares

What this does is, that anytime the route /.well-known/{someFile} is called, it overrides the default config option hidden that is false (which prevents exposing dot files). This middleware only affects the .well-known folder, any other dot file will stay unexposed.

Hope this helps!

1 Like