0

I have used AWS server and Laravel 5.5. So main domain point to main ec2 instance, and sub domain pointing to sub ec2 instances.

I have Project that require to manage and multiple subdomain and main domain. i.e Main Domain is testdemo.com and others are xyz.testdemo.com, abc.testdemo.com etc.

In Subdomain I have a single file, and put it one line as include to main domain main file url. But When I do Form Post from subdomain, it gives me error 419 (token mismatch error).I have tried many things. tokenmismatch error solution (included token inside form).

Please check below image that is in subdomain :

 <?php
# Enable Error Reporting and Display:
error_reporting(~0);
ini_set('display_errors', 1);
$url = 'https://www.testdemo.com/abc';
include($url);
?>

Can any one help me out?

dev_la
  • 31
  • 3
  • Instead of including the url, why can't you just add an A record to the subdomain which will point it to the main ec2? – Shuvojit Apr 11 '19 at 13:01
  • As far as I can understand, the issue you're facing is that, the csrf token is generated wrt to the subdomain and is stored on it's session, whereas when you submit the form it gets evaluated under the main domain's session, thus the mismatch. – Shuvojit Apr 11 '19 at 13:03
  • @Shuvojit : I'm creating subdomain programmatically, so just add this url and include url. – dev_la Apr 11 '19 at 13:04
  • Found a similar issue on laracast: https://laracasts.com/discuss/channels/laravel/sharing-csrf-token-subdomain-domain – Shuvojit Apr 11 '19 at 13:07
  • @Shuvojit : No, this above code is only file in subdomain that include main domain url. So when I try to open login screen (that view actually in main domain) that opens proper and creates token to main domain. Now when I try to post form from subdomain it goes to main domain only. – dev_la Apr 11 '19 at 13:13
  • @Shuvojit : Yes I have add SESSION_DOMAIN=.testdemo.com in my env file, but still no luck – dev_la Apr 11 '19 at 13:19

0 Answers0