All you need is to add proxy rule to routeRules in Nuxt config and change baseURL fetch option:
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:
export default defineNuxtConfig({
routeRules: {
'/petsProxy/**': {
proxy: {
to: 'https://petstore3.swagger.io/api/v3/**',
cookieDomainRewrite: {
'*': '',
},
}
}
}
})