Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel app is not creating XSRF-TOKEN cookie #32

Open
mhetreramesh opened this issue Jan 14, 2021 · 2 comments
Open

Laravel app is not creating XSRF-TOKEN cookie #32

mhetreramesh opened this issue Jan 14, 2021 · 2 comments
Labels
support Someone needs help

Comments

@mhetreramesh
Copy link

mhetreramesh commented Jan 14, 2021

As per laravel docs, every application should create encrypted XSRF-TOKEN cookie. I also have this cookie on my dev environment but not on lambda function.

This is the cookie missing on lambda function.
image

I've tried adding custom header for lambda function in serverless file, like:

functions:
  # This function runs the my website/API
  web:
    handler: public/index.php
    timeout: 28 # in seconds (API Gateway has a timeout of 29 seconds)
    layers:
      - ${bref:layer.php-74-fpm}
      - ${bref:extra.gd-php-74}
    events:
      - httpApi: '*'
        cors:
          origin: '*'
          headers:
            - X-XSRF-TOKEN

I use this to on the frontend(Inertia) application for axios requests.

Does someone has any idea if I'm missing something?

@mnapoli mnapoli added the support Someone needs help label Jan 14, 2021
@aristidesneto-bnw
Copy link

Did you manage to solve it?

I managed to solve it by going straight to the CloudFront panel and adding the X-CSRF-TOKEN header to the Policy (custom policies -> cache key settings).

But using the serverless.yml file I had no success following as described in the documentation https://github.com/getlift/lift/blob/master/docs/server-side-website.md#forwarded-headers.

I would not like to add the header manually through CloudFront, but through the serverless.yml configuration file

@evrend
Copy link

evrend commented May 7, 2022

@aristidesneto-bnw Thank you very much for the serverless-lift doc's link. After 3-4 hours, finally, I solved the X-CSRF-TOKEN header problem. I added X-CSRF-TOKEN header to serverless.yml as in the serverless-lift documents. And it works perfectly.

constructs:
    website:
        type: server-side-website
        domain: ***********
        certificate: arn:aws:************
        forwardedHeaders:
            - X-XSRF-TOKEN
            - Origin
            - Accept
            ....

Result:

image

mnapoli pushed a commit that referenced this issue Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Someone needs help
Projects
None yet
Development

No branches or pull requests

4 participants