Вопрос

I'm running an AngularJS app and I'm using the grunt-contrib-connect plugin to host my stuff. I'd like some PDF files to be accessed in the browser (tested in all of them), but the pages stay blank. It does show the correct amount of pages, though. I've exported the PDF from a .doc-file using both Word and Pages, but the result stays the same.

I wrote this little middleware snippet to ensure the headers are set (and they are, according to Chrome's Network tab), but the pages stay blank. Any help?

In my Gruntfile;

grunt.initConfig({
    settings: {}, // ...
    connect: {
        livereload: {
            middleware: function(connect) {
                var middlewares = [];
                // Other middlewares
                middlewares.push(function (req, res, next) {
                    if (~req.url.indexOf('.pdf')) {
                        res.setHeader('Content-type', 'application/pdf');
                    }
                    return next();
                });

                return middlewares;
            }
        } 
    } 
});
Это было полезно?

Решение

It seems grunt-contrib-connect has problems serving binary files: https://github.com/gruntjs/grunt-contrib-connect/issues/142

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top