RobertPorter
RobertPorter

Reputation: 552

Redirect with grunt-contrib-proxy

I might be doing something wrong but I am unable to force grunt-contrib-proxy to do a simple redirect.

In my gruntfile.coffeee (yup coffeescript) I have the following server configuration:

 connect:
        devserver:
            options:
                port: 9001
                base: "./"
            proxies: [{
                context: "/",
                host: 'dev.staging.com'
                changeOrigin: true
            }]

I also added: grunt.loadNpmTasks "grunt-connect-proxy" and updated my task with "configureProxies:devserver"

I believe that this should redirect any call to dev.staging.com, so when I type in http://localhost:9001 i should be redirected to url http://dev.staging.com

However it doesn't seem like proxy is workign at all. I have tried multiple configurations (even with rewrite) but still no luck.

I might be doing something wrong but i can't figure what...

Grunt compiles and runs the task properly.

Upvotes: 1

Views: 130

Answers (1)

RobertPorter
RobertPorter

Reputation: 552

It appears that documentation is missing the important fact thay you MUST add middleware to your server options:

proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest

middleware: (connect, options) => return [proxySnippet]

Upvotes: 1

Related Questions