@spruce-hub/nuxt-fetch

Secure and easy http proxy integration with Nuxt.js
793
Install
npm install @spruce-hub/nuxt-fetch
Latest Version:1.11.1
Vue:3
License:MIT
Last Updated:Sep 26, 2023
Links: npm
Maintainer: zzl821

@spruce-hub/nuxt-fetch

Usage

npm install @spruce-hub/nuxt-fetch --save
# or
pnpm add @spruce-hub/nuxt-fetch -P

Quick start

// nuxt.config.ts
export default defineNuxtConfig({
  modules: [
    [
      '@spruce-hub/nuxt-fetch',
      {
        '/api': {
          pathRewrite: {
            '^/api': 'api',
          },
          apiHostEnv: 'API_HOST',
          apiHostUrl: 'http://api.com',
          cookieName: 'access_token',
        },
        '/api2': {
          pathRewrite: {
            '^/api2': '/api',
          },
          apiHostEnv: 'API_HOST',
          apiHostUrl: 'http://api2.com',
          cookieName: 'access_token',
        },
      },
    ],
  ],
})
const { data, pending, error, refresh } = await useFetch('/api/example')

// http://localhost/api/example => http://myapi.com/api/example

License

MIT

Copyright (c) 2023-present, Spruce FE

Related Packages

@spruce-hub/cui

适用于 (S)CRM 平台的公共组件或模块

895

Version History

Version Released Vue License
1.11.1 ^3.0 MIT
1.11.0 ^3.0 MIT
1.9.0 ^3.0 MIT
1.8.0 ^3.0 MIT
1.7.1 ^3.0 MIT