{"library":"nuxt-proxy","title":"Nuxt Proxy Middleware","description":"nuxt-proxy is a Nuxt 3 module that integrates `http-proxy-middleware` and `h3` to provide HTTP proxying capabilities directly within a Nuxt application. It enables developers to configure declarative proxy rules in `nuxt.config.ts`, facilitating the routing of specific client-side API requests to backend servers. This is commonly used to circumvent CORS restrictions or to unify API endpoints under a single origin. The current stable version is 0.4.1. Releases typically focus on bug fixes, dependency updates (e.g., `h3`, `@nuxt/kit`), and minor feature enhancements such as runtime configuration overrides. Its key differentiator is a streamlined, module-based setup within the Nuxt ecosystem, leveraging Nuxt's Nitro server for efficient middleware handling, offering a more integrated solution than manually setting up a proxy.","language":"javascript","status":"active","last_verified":"Thu Apr 23","install":{"commands":["npm install nuxt-proxy"],"cli":null},"imports":["export default defineNuxtConfig({\n  modules: [\n    'nuxt-proxy'\n  ],\n  // ...\n})","export default defineNuxtConfig({\n  proxy: {\n    options: {\n      target: 'https://jsonplaceholder.typicode.com',\n      changeOrigin: true\n    }\n  }\n})","export default defineNuxtConfig({\n  runtimeConfig: {\n    proxy: {\n      options: { target: process.env.NUXT_PROXY_OVERRIDE_TARGET ?? 'https://jsonplaceholder.typicode.com' }\n    }\n  }\n})"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { defineNuxtConfig } from 'nuxt';\n\nexport default defineNuxtConfig({\n  modules: [\n    'nuxt-proxy'\n  ],\n  proxy: {\n    options: {\n      target: process.env.NUXT_PROXY_TARGET ?? 'https://jsonplaceholder.typicode.com',\n      changeOrigin: true,\n      pathRewrite: {\n        '^/api/todos': '/todos',\n        '^/api/users': '/users'\n      },\n      pathFilter: [\n        '/api/todos',\n        '/api/users'\n      ]\n    }\n  },\n  // Example of using runtimeConfig for proxy options\n  runtimeConfig: {\n    proxy: {\n      options: {\n        target: process.env.NUXT_RUNTIME_PROXY_TARGET ?? 'https://jsonplaceholder.typicode.com'\n      }\n    }\n  }\n});\n\n// In a Vue component or server route (e.g., pages/index.vue)\n// <script setup>\n// const { data: todos } = await useFetch('/api/todos');\n// console.log('Fetched Todos:', todos.value);\n// const { data: users } = await useFetch('/api/users');\n// console.log('Fetched Users:', users.value);\n// </script>","lang":"typescript","description":"Demonstrates how to enable `nuxt-proxy` as a module, configure basic proxy rules in `nuxt.config.ts` including `target`, `pathRewrite`, and `pathFilter`, and show how client-side `useFetch` interacts with the proxied endpoints. It also includes an example of runtime configuration.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}