module.exports = (chromium) => {
  return async (req, res, next) => {
    
    const browser = await chromium.launch({ 
      args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-gpu', '--disable-dev-shm-usage'],
      headless: true 
    });
    
    req.playwrightBrowser = browser;
    next();
  }
}