Pregunta

Is it possible and if so how can one specify custom headers with grunt-contrib-connect?

¿Fue útil?

Solución

You can write your own middleware and specify req.headers like such:

grunt.initConfig({
    connect: {
        server: {
            options: {
                middleware: function(connect, options) {
                    return [
                        function(req, res, next) {
                            // If path has .json, accept json
                            if (url.parse(req.url).pathname.match(/\.json$/)) {
                                req.headers.accept = 'application/json';
                            }
                            next();
                        },
                        // then serve a static folder
                        connect.static('base/folder/')
                    ]
                },
            }
        }
    },
});
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top