Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow middleware to access build-time res.statusCode and res.body #30

Open
zachleat opened this issue May 18, 2022 · 0 comments
Open

Allow middleware to access build-time res.statusCode and res.body #30

zachleat opened this issue May 18, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@zachleat
Copy link
Member

Related to #29.

This is what works now:

const { EleventyServerlessBundlerPlugin } = require("@11ty/eleventy");

module.exports = function(eleventyConfig) {
  eleventyConfig.setServerOptions({
    middleware: [function overrideMiddleware(req, res, next) {
      // This works now
      res.writeHead(200, {"content-type": "text/html"}); // content-type header required for live-reload
      res.write("Before Text");
      res.end();

      next();
    }],
  });
});

However, I’d like to see folks able to consume res.statusCode (404 when no file is present) and res.body with the static content to do request-time content transforms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant