Socket
Socket
Sign inDemoInstall

@nuxtjs/proxy

Package Overview
Dependencies
42
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @nuxtjs/proxy

> The one-liner node.js http-proxy middleware solution for Nuxt.js using [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware)


Version published
Weekly downloads
149K
decreased by-15%
Maintainers
1
Install size
2.17 MB
Created
Weekly downloads
 

Changelog

Source

1.1.0 (2017-06-07)

Bug Fixes

  • proxy: normalize target in object mode (e9d4026)

Features

Readme

Source

Proxy

The one-liner node.js http-proxy middleware solution for Nuxt.js using http-proxy-middleware

Notice: As a limitation currently this module only works with nuxt internal server. For express,... you may have to manually register nuxt.serverMiddleware. (Will be fixed soon)

Features

  • Path rewrites
  • Host based router (useful for staging/test)
  • Logs / Proxy Events
  • WebSockets
  • Auth / Cookie
  • ... and more! (see http-proxy-middleware docs)

Setup

  • Add @nuxtjs/proxy dependency using yarn or npm to your project
  • Add @nuxtjs/proxy module to nuxt.config.js:
modules: [
 '@nuxtjs/proxy'
]
  • [optional] You can also provide default options to all proxy targets:
    • By default changeOrigin and ws options are already enabled.
    • See http-proxy-options for available options.
modules: [
 {
   src: '@nuxtjs/proxy',
   pathRewrite: {
     '^/api' : '/api/v1' // Rewrite path
   }
 }
]
  • Define as many as proxy middleware you want in proxy section of nuxt.config.js: (see section below)

Proxy Options

You can provide options using either object or array form.

Array mode (You can use magic shorthands)

  proxy: [
    // Proxies /foo to http://example.com/foo
    'http://example.com/foo',
  
    // Proxies /api/books/*/**.json to http://example.com:8000
    'http://example.com:8000/api/books/*/**.json',

    // You can also pass more options
    [ 'http://example.com/foo', { ws: false } ]
  ]

Object mode (Keys are context)

  proxy: {
    // Simple proxy
    '/api': 'http://example.com',
    
    // With options
    '/api2': { target: 'http://example.com', ws: false }
  }

FAQs

Last updated on 07 Jun 2017

Did you know?

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc