I have a laravel application set up with the api stack of breeze and a nextjs application where i use the useAuth hook of the official laravel nextjs starterkit.
My axios configuration looks like this:
import Axios from 'axios'
const axios = Axios.create({
baseURL: process.env.NEXT_PUBLIC_BACKEND_URL,
headers: {
'X-Requested-With': 'XMLHttpRequest',
},
withCredentials: true,
})
export default axios
and the hook can be found here: https://github.com/laravel/breeze-next/blob/master/src/hooks/auth.js
locally everything works great because the laravel api and nextjs frontend run on the same domain 'localhost'
however on production both the frontend and api are on completely different domains. This results in axios not setting the X-XSRF-TOKEN header with the request, and the cookies for laravel-session and XSRF-TOKEN not being set on the client.
How can i allow this to work with cross domain?