-
I've got a small inertia app which gets loaded into another domain through an Iframe. If i want to update something server side I make a request in the vue-component via: this.$inertia.post(
`/add-to-cart?ulid=${this.ulid}`,
{ test: 1234 }
); Serverside, in my controller I perform some logic en redirect the request to a second page: return \Redirect::route('cart', [
'ulid' => $request->get('ulid')
])
->withMessage([
'label' => 'bijgewerkt',
'type' => 'cart-bijgewerkt'
]); If I visit the app on its own domain (so not iframed) this redirect works like expected. I end up on the But when the app is being iFramed, it does not work. Even when I just replace the whole controller method with a I'm a little bit lost on why this redirect is happening or even where it comes from! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
This is probably a Token Mismatch Redirect because of the "Lax" SameSite policy. The XSRF-TOKEN cookie cannot be accessed when posting to your server via an Iframe. Jonathan has sum up some more information here: https://inertiajs.com/csrf-protection. You can try to share the token as a prop and then include it in the post data, as mentioned in the beginning of the article. There may be also other solutions availabe. But they require a more deep understanding what SameSite cookies are and how you need to configure them to keep your app secure. |
Beta Was this translation helpful? Give feedback.
This is probably a Token Mismatch Redirect because of the "Lax" SameSite policy. The XSRF-TOKEN cookie cannot be accessed when posting to your server via an Iframe.
Jonathan has sum up some more information here: https://inertiajs.com/csrf-protection. You can try to share the token as a prop and then include it in the post data, as mentioned in the beginning of the article.
There may be also other solutions availabe. But they require a more deep understanding what SameSite cookies are and how you need to configure them to keep your app secure.