Laravel Project as iFrame -> Page expired when loggin in
Hey community,
I created a Laravel Application and want to embed it into another site via iFrame. Firstly you have to sign-in in my Application, but when the form gets submited I get a 419 Page expired problem.
When I try it directly without an iFrame, that its no problem... so what is the solution?
please help me guys.. i had a huge project and now we want to go live and it depends on this little thing... whats the alternative? I want to show my app in an iframe - that was the aim for this project :/
From your description it sounds like they are different domains, is that correct?
Also, and this I'm not 100% sure of, but if the iframe is another domain, I think the session has to be used via url.
I have loaded sites in an iframe, but a login wasn't required. It's been a while but it was adoptapet.
But sorry if my links above are wrong, I was just trying to help. And normally those two sites have good answers.
@jeffreyway if you see this, any thoughts on cross domain iframe? It's got me wondering now.
Try changing the value of same site cookie policy in config/sessions.php
/*
|--------------------------------------------------------------------------
| Same-Site Cookies
|--------------------------------------------------------------------------
|
| This option determines how your cookies behave when cross-site requests
| take place, and can be used to mitigate CSRF attacks. By default, we
| will set this value to "lax" since this is a secure default value.
|
| Supported: "lax", "strict", "none", null
|
*/
'same_site' => 'lax',
currently the cookies are blocked because of the 'lax' setting.
remember to clear or reset config cache after changing.
To see the issue:
Open Chrome dev tools. select the network tab. Click login on the iframe.
You will see a red Login in the left panel, click this.
On the right panel, click cookies
check the box for 'show filtered out request cookies'
you will see request cookies for XSRF-TOKEN and Laravel_session are blocked
@Snapey I set it to none or null, but it does not help: in iframe the post request fails with 419, when I open the iframe in a new browser tab, the post request works fine.
You were right, when in iframe it does not sent/receive csrf token and the cookie.
Things would be a lot easier if the client could provide a subdomain to host your site on. Then you could iframe within the same domain, or not use iframe, use ihre-baustelle.flo-photo.at
i searched, but there are not really helpfull solutions... i tested on ios (iphone x) with safari and chrome - both have the page expired problem like on desktop before i made the change from same_site from "lax" to "none"...