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?
Static file serving in Keystonejs 6
375 views Asked by ConductedClever At
1
you can create a folder named
public
, then underextendExpressApp
add the following codeapp.use("/public", express.static("public"));
(follow express documentationhttps://expressjs.com/en/starter/static-files.html
)add this line under
ui
publicPages: ["public"],
to skip admin authenticationnow your public folder should be accessible.