Blog

Vue 3 and Axios: withCredentials, baseURL, and CORS configuration for SPAs

Set axios.defaults.withCredentials only when your API explicitly allows credentials in CORS.

1 min read
vueaxioscors

Vite dev server

Mirror Angular-style proxying with vite.config server.proxy for local APIs.

HMR websocket origin differs from API origin—do not confuse the two when debugging CORS.

Composition API

Wrap fetch calls in composables that centralize error handling for 401 and CORS failures.

Expose a typed client for Nuxt server routes to share validation logic.

Back to blog