I want the functionality of connect.static, but I want to inject code into any HTML and JavaScript files that are served.
- Can I hook into
connect.staticto modify the data it serves? - Is there a better approach?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
connect.static isn’t the right choice for this. The static middleware is specifically for serving static content directly from disk.
Look at connect-assetmanager (https://github.com/mape/connect-assetmanager), it has a serveModify hook that should do what you’re needing.