Détail du package

@nuxtjs/proxy

nuxt-community689.8kMIT2.1.0

proxy support for nuxt server

readme

@nuxtjs/proxy

npm version npm downloads codecov license

Proxy support for nuxt server

📖 Release Notes

Features

✓ Path rewrites

✓ Host based router (useful for staging/test)

✓ Logs / Proxy Events

✓ WebSockets

✓ Auth / Cookie

✓ ...See http-proxy-middleware docs

⚠ Does not work in generated/static mode!

Setup

  1. Add @nuxtjs/proxy dependency to your project
yarn add @nuxtjs/proxy # or npm install @nuxtjs/proxy
  1. Add @nuxtjs/proxy to the modules section of nuxt.config.js
{
  modules: [
    // Simple usage
    '@nuxtjs/proxy',

    // With options
    ['@nuxtjs/proxy', { pathRewrite: { '^/api' : '/api/v1' } }]
  ]
}
  • Define as many as proxy middleware you want in proxy section of nuxt.config.js (See proxy section below)

Options

  • changeOrigin and ws options are enabled by default.

[optional] You can provide default options to all proxy targets by passing options to module options.

proxy

You can provide proxy config using either object or array.

Array Config

You can use shorthand syntax to configure proxy:

{
  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 Config

Keys are context

{
  proxy: {
    // Simple proxy
    '/api': 'http://example.com',

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

    // Proxy to backend unix socket
    '/api3': {
      changeOrigin: false,
      target: { socketPath: '/var/run/http-sockets/backend.sock' }
    }
  }
}

Development

  1. Clone this repository
  2. Install dependencies using yarn install or npm install
  3. Start development server using npm run dev

License

MIT License

Copyright (c) Nuxt Community

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

2.1.0 (2020-12-14)

Features

  • update module (typescript rewrite) (c9dad3c)

2.0.1 (2020-07-16)

Bug Fixes

  • skip module for nuxt build (fixes #74) (50db85e)

2.0.0 (2020-06-03)

⚠ BREAKING CHANGES

  • Bumping major version as http-proxy-middleware may introduce some usage regressions

Features

  • bump to 2.x (57eb492)
  • upgrade to http-proxy-middleware 1.0.1 (0277f6d)

Bug Fixes

1.3.3 (2019-03-02)

Bug Fixes

  • module: generate warn if not SPA and increase coverage (#31) (8baafc9)

1.3.2 (2019-02-18)

Bug Fixes

  • skip generate warn for now because of SPA (7b23097)

1.3.1 (2018-10-30)

Bug Fixes

  • add hint for "universal" mode only (#10) (c78b122)

1.3.0 (2018-10-29)

Features

1.2.4 (2018-03-31)

1.2.3 (2018-03-31)

Bug Fixes

1.2.2 (2018-03-31)

1.2.1 (2018-03-31)

1.2.0 (2018-03-31)

1.1.4 (2018-01-28)

1.1.3 (2017-11-20)

Note: Version bump only for package @nuxtjs/proxy

1.1.2 (2017-09-05)

Bug Fixes

1.1.1 (2017-06-09)

Bug Fixes

  • plugin: normalize array alternative form path (811b5a9)

1.1.0 (2017-06-07)

Bug Fixes

  • proxy: normalize target in object mode (e9d4026)

Features