all repos — caroster @ c1a6f1a4eafac48d7b5a72429fa5c450805f3825

[Octree] Group carpool to your event https://caroster.io

backend/middlewares/next-proxy/index.js (view raw)

 1const proxy = require('koa-proxy');
 2
 3module.exports = strapi => ({
 4  async initialize() {
 5    const {host = '', conf = {}} = strapi.config.middleware.settings[
 6      'next-proxy'
 7    ];
 8
 9    strapi.router.get('/', proxy({host, ...conf}));
10
11    strapi.app.use(async (ctx, next) => {
12      await next();
13
14      if (ctx.response.status === 404) {
15        await proxy({host, ...conf})(ctx);
16      }
17    });
18  },
19});