import fs from 'fs';

const sapRoutes = [
  '/User',
  '/Careers',
  '/Organizations',
  '/About',
  '/Contact',
  '/User',
];

export default (app) => {
  sapRoutes.forEach(route => app.use((ctx, next) => {
    if (ctx.url !== route) return next();
    ctx.path = route;
    ctx.redirect('/', route);
    // ctx.respond = false;

    // const rs = fs.createReadStream(`${process.cwd()}/dist/index.html`);
    // const body = [];
    // rs
    // .on('error', (err) => console.error(err))
    // .on('data', (chunk) => body.push(chunk))
    // .on('end', () => {
    //   ctx.res.writeHead(200, {
    //     'Content-Type': 'text/html',
    //     Location: route,
    //   });
    //   ctx.res.end(Buffer.concat(body).toString());
    // });
  }));
};

@@ -1,8 +1,11 @@
+// 
 import f
@@ -38,27 +38,16 @@
 tes = %5B%0A
-  '/User',%0A
   '/Care
@@ -239,30 +239,8 @@
 ();%0A
-    ctx.path = route;%0A
     
@@ -269,36 +269,566 @@
 e);%0A
-    // ctx.respond = false;%0A
+%0A    // const %7B req, res %7D = ctx;%0A    // const protocol = req.socket.encrypted ? 'https' : 'http';%0A    // const Location = %60$%7Bprotocol%7D//$%7Breq.headers.host%7D$%7Broute%7D%60;%0A    // res.writeHead(200, %7B%0A    //   'Content-Type': 'text/html',%0A    //   Location,%0A    // %7D);%0A    // ctx.type = 'html';%0A    // ctx.body = fs.createReadStream(%60$%7Bprocess.cwd()%7D/dist/index.html%60);%0A%0A    // ctx.respond = false;%0A    // const %7B req, res %7D = ctx;%0A    // const protocol = req.socket.encrypted ? 'https' : 'http';%0A    // const Location = %60$%7Bprotocol%7D//$%7Breq.headers.host%7D$%7Broute%7D%60;
 %0A   
@@ -1061,28 +1061,24 @@
  %7B%0A    //   
-ctx.
 res.writeHea
@@ -1149,15 +1149,8 @@
 tion
-: route
 ,%0A  
@@ -1169,20 +1169,16 @@
    //   
-ctx.
 res.end(
@@ -1221,16 +1221,33 @@
  // %7D);%0A
+    return null;%0A
   %7D));%0A%7D

fix server route redirection