drewzboto / grunt-connect-proxy

Grunt Connect support for proxying API calls during development
MIT License
423 stars 122 forks source link

Failed to load resource: net::ERR_SSL_PROTOCOL_ERROR and 301 #77

Open joshrouwhorst opened 10 years ago

joshrouwhorst commented 10 years ago

Hey, I'm getting the above error when I try to use proxies.

Here's my connect options:

connect: {
            options: {
                port: 9000,
                // Change this to '0.0.0.0' to access the server from outside.
                hostname: 'localhost',
                protocol: 'http',
                livereload: 35729
            },
            proxies: {
                context: ['/api'],
                host: 'wwwdev.internal.*******.com',
                https: false,
                changeOrigin: true,
                xforward: false,
                rejectUnauthorized: false,
                rewrite: {
                    '^/api': '/app/api'
                }
            },
            livereload: {
                options: {
                    open: true,
                    base: [
                        '.tmp',
                        '<%= yeoman.app %>'
                    ],
                    middleware: function (connect) {
                        return [
                          proxySnippet,
                          mountFolder(connect, '.tmp'),
                          mountFolder(connect, 'app')
                        ];
                    }
                }
            },
            test: {
                options: {
                    port: 9001,
                    base: [
                        '.tmp',
                        'test',
                        '<%= yeoman.app %>'
                    ]
                }
            },
            dist: {
                options: {
                    port: 3000,
                    base: '<%= yeoman.dist %>',
                    middleware: function (connect) {
                        return [
                          proxySnippet,
                          mountFolder(connect, 'dist')
                        ];
                    }
                }
            }
        },

And my serve task:

grunt.registerTask('serve', function (target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'connect:dist:keepalive']);
        }

        grunt.task.run([
            'clean:server',
            'bowerInstall',
            'concurrent:server',
            'autoprefixer',
            'configureProxies',
            'connect:livereload',
            'watch'
        ]);
    });

I've tried using https: true but that gives me the same error.

I noticed that when I do a POST to /api/account it first returns with a status 301 Moved Permanently then it immediately does a GET request to /app/api/account which seems to be the request actually throwing the error.

I'd really appreciate any input you can give. Thanks!

grunt-connect-proxy v0.1.11 grunt-contrib-connect v0.5.0 grunt v0.4.5

joshrouwhorst commented 10 years ago

Well, I solved this for myself, I had to roll back to v0.1.10 and now it's working for me.