2.1.2 • Published 3 years ago

@nuxtjs-alt/proxy v2.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Information

This serves as an alternative for @nuxtjs-alt/proxy. Please note that his is for nuxt3 only.

Other Information

This module creates a file in your buildDir called nuxt-http-proxy.ts which will handle all of the proxying you set within your nuxt config. The config is similar to what vite has except that this one creates a physical file which is needed for production.

Version 2.0+ New options have been added to the proxy module. The proxies now need to be moved into a proxies property (example provided below). A fetch property has been added so that proxying applies to the native $fetch in nitro and via client side. An enableProxy property has been added if you would like to disable the http-proxy creation for some reason.

Configuration

The configuration looks similar to that of vite's server proxy config, only difference is that it's passed through to nuxt server handler.

import { defineNuxtConfig } from 'nuxt/config'

export default defineNuxtConfig({
    modules: [
        '@nuxtjs-alt/proxy',
    ],
    proxy: {
        enableProxy: true,
        proxies: {
            // string shorthand
            '/foo': 'http://localhost:4567',
            // with options
            '/api': {
                target: 'http://jsonplaceholder.typicode.com',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, '')
            },
            // with RegEx
            '^/fallback/.*': {
                target: 'http://jsonplaceholder.typicode.com',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/fallback/, '')
            },
            // Using the proxy instance
            '/api': {
                target: 'http://jsonplaceholder.typicode.com',
                changeOrigin: true,
                configure: (proxy, options) => {
                    // proxy will be an instance of 'http-proxy'
                }
            },
            // Proxying websockets or socket.io
            '/socket.io': {
                target: 'ws://localhost:5173',
                ws: true
            }
        },
        fetch: true
    }
})
2.1.2

3 years ago

2.0.5

3 years ago

2.0.7

3 years ago

2.0.6

3 years ago

2.1.0

3 years ago

1.3.7

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.4

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.3.8

3 years ago

1.3.5

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.2.8

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.9

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.2.2

3 years ago

1.1.3

3 years ago

1.2.1

3 years ago

1.1.2

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.0

3 years ago