I am using Keystonejs 6 and some models contain image type fields. When fetching this data I get a src of that image which points to /public/images/myimage.png. This link successfully gets loaded with admin panel logged in (session created) but when I request this src address from a browser anonymously, it redirects my request to the signin
page. I can't find setup guide about static serving in Keystone 6. Although in Keystone 5 it seems exist in the documentation, in Keystone 6 nothing I can find in documents or community forum. Does Keystone 6 supports anonymous static file serving (serving public directory) and if it is possible how can I do this?
you can create a folder named public
, then under extendExpressApp
add the following code
app.use("/public", express.static("public"));
(follow express documentation https://expressjs.com/en/starter/static-files.html
)
add this line under ui
publicPages: ["public"],
to skip admin authentication
now your public folder should be accessible.