Express middleware

Hi there, I’m evaluating Frontity for use on our site, currently we have express middleware which adds oauth authentication to all our node apps, as our side is only for logged in users and it handles kicking them to the login screen etc.

Would there be a way to add this auth layer to Frontity? From looking through the docs I gather you used to use Express but not anymore?


Hi Neil, welcome to the community and sorry for the delay in our answer :slight_smile:

Do you want to use the auth of WordPress or do you have a separate user system?

About this: we used Express in our old internal version of the framework, but Express is not well suited for serverless, so we switched to Koa for the this open sourced version.

Adding server extensibility is one of our next steps. It’s going to work with a different export, probably server.

Something like this:

// The normal package export.
export default {

// The server middleware export.
export const server = ({ app }) => {
  app.use(ctx => {
    // Add some headers...
       SomeHeader: "Value of the header",
       OtherHeader: "Value of the header"
  // Create custom routes....
  app.use(route('/custom-route', ctx => {
    ctx.body = 'Some body content';

In order to avoid including the server code in the client bundle, you can split your src/index.js file in a src/client.js and a src/sever.js file.

Hi Luis

Yeah it’s our own auth system seperate to wordpress. We basically have a middleware that we apply to all our express servers which adds the oauth2 endpoints for authenticating all requests.

Hmm so it sounds like i would need to wait for the server extensibility to be added, then rework the module a bit to work with Koa rather than Express

That’s it! :smile:

I’ll let you know in this topic once it’s ready.