Setup
Proxy
Proxy setup is pretty straightforward with Nuxt's built-in routeRules
All you need is to add proxy rule to routeRules
in Nuxt config and change baseURL
fetch option:
nuxt.config.ts
export default defineNuxtConfig({
openFetch: {
clients: {
pets: {
baseURL: '/petsProxy'
}
}
},
routeRules: {
'/petsProxy/**': { proxy: 'https://petstore3.swagger.io/api/v3/**' }
}
})
You can also use ProxyOptions object to configure proxy behaviour.
F.e, remove domain
attributes in the set-cookie
headers:
nuxt.config.ts
export default defineNuxtConfig({
routeRules: {
'/petsProxy/**': {
proxy: {
to: 'https://petstore3.swagger.io/api/v3/**',
cookieDomainRewrite: {
'*': '',
},
}
}
}
})