简体   繁体   中英

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.

资源

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM