Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grunt-connect-proxy

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-connect-proxy

Provides an http proxy as middleware for grunt connect.

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.6K
decreased by-62.39%
Maintainers
1
Weekly downloads
 
Created
Source

grunt-connect-proxy

Provides an http proxy as middleware for the grunt-contrib-connect plugin.

Getting Started

This plugin requires Grunt ~0.4.0

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-connect-proxy --save-dev

One the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-connect-proxy');

Adapting the "connect" task

Overview

Proxy Configuration

In your project's Gruntfile, add a section named proxies to your existing connect definition.

grunt.initConfig({
    connect: {
            options: {
                port: 9000,
                hostname: 'localhost'
            },
            proxies: [
                {
                    context: '/cortex',
                    host: '10.10.2.202',
                    port: 8080,
                    https: false,
                    changeOrigin: false
                }
            ]
        }
})

Adding the middleware Expose the proxy function to use in the middleware, at the top of the grunt file:

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

Add the middleware call from the connect option middleware hook

        connect: {
            livereload: {
                options: {
                    middleware: function (connect) {
                        return [
                            proxySnippet
                        ];
                    }
                }
            }
        }

Adding the configureProxy task to the server task

For the server task, add the configureProxies task before the connect task

    grunt.registerTask('server', function (target) {
        grunt.task.run([
            'clean:server',
            'compass:server',
            'configureProxies',
            'livereload-start',
            'connect:livereload',
            'open',
            'watch'
        ]);
    });

Options

The available configuration options from a given proxy are generally the same as what is provided by the underlying httpproxy library

options.context

Type: String

The context to match requests against. Matching requests will be proxied. Should start with /. Should not end with /

options.host

Type: String

The host to proxy to. Should not start with the http/https protocol.

options.port

Type: Number Default: 80

The port to proxy to.

options.https

Type: Boolean Default: false

Whether to proxy with https

options.changeOrigin

Type: Boolean Default: false

Whether to change the origin on the request to the proxy, or keep the original origin.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

0.1.0 Initial release

Keywords

FAQs

Package last updated on 07 Mar 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc