Search code examples
xcodedockerdockerfilevaporleaf

Vapor `Public` directory inside docker image is not exposed


I'm running Vapor 4.3 and Leaf with Xcode on my Mac without any issues.

public directory middleware is enabled:

let fileMW = FileMiddleware(publicDirectory: directory)
app.middleware.use(fileMW)

as soon as I build the image using the default dockerfile and run it on the docker, the css and all image files are not loaded anymore.

Note: the dockerfile is the exact same one that came with the vapor new command. (Updated to the date of the writing this post)

Safari shows this error:

[Error] Did not parse stylesheet at 'http://127.0.0.1/styles/index.css' because non CSS MIME types are not allowed in strict mode.

resources

Chrome shows this warning:

Resource interpreted as Stylesheet but transferred with MIME type text/plain: "http://127.0.0.1/styles/index.css".

What am I missing?


Solution

  • Looks like it is a case sensitivity issue! Mac has no problem finding files with this issue but Linux not!

    ⚠️ Even if you already set: app.routes.caseInsensitive = true, it will not affect your resources requests.

    So make sure you have set all paths exactly as they appear in pwd command.