#dwinpaez - PHP Checkout CORS Issue
1 messages · Page 1 of 1 (latest)
Hi
Request URL: https://checkout.stripe.com/pay/cs_test_a12yhL1yoEYQD5lhzB3sXPSbsjgnmEpMIQ3ZCYMTgBwmlT2n6dOmkKhb46
Request Method: OPTIONS
Status Code: 403
Remote Address: 151.101.136.176:443
Referrer Policy: strict-origin-when-cross-origin
accept-ranges: bytes
content-length: 0
date: Wed, 16 Mar 2022 22:17:55 GMT
retry-after: 0
server: Varnish
strict-transport-security: max-age=31556926; includeSubDomains; preload
via: 1.1 varnish
x-cache: MISS
x-cache-hits: 0
x-served-by: cache-yul12823-YUL
x-timer: S1647469076.762576,VS0,VE0
:authority: checkout.stripe.com
:method: OPTIONS
:path: /pay/cs_test_a12yhL1yoEYQD5lhzB3sXPSbsjgnmEpMIQ3ZCYMTgBwmlT2n6dOmkKhb46
:scheme: https
accept: /
accept-encoding: gzip, deflate, br
accept-language: en-CA,en;q=0.9,en-GB;q=0.8,en-US;q=0.7,es;q=0.6,fr;q=0.5
access-control-request-headers: x-requested-with
access-control-request-method: GET
origin: https://enfermerascanada.com
referer: https://enfermerascanada.com/
sec-fetch-dest: empty
sec-fetch-mode: cors
sec-fetch-site: cross-site
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36
Enfermeras en Canadá - Guío enfermeros latinos que estén interesados en Canadá
Enfermeras en Canadá - Guío enfermeros latinos que estén interesados en Canadá
What's the actual CORS error you're seeing?
Those are just details about the request, not the error itself.
Ah, okay, so you're handling the redirect wrong. It looks like you're trying to get the URL of the Checkout Session in your JavaScript, but instead of returning the URL your server is trying to redirect to the URL.
There are two ways to fix it: 1) you can change your client-side code so it sends people to that URL instead of trying to fetch it, or 2) you can change your server-side code so it no longer tries to redirect and instead returns the URL.
iam doing that:
Doing what?
The redirect shown in that screenshot? Yeah, that combined with your client-side code is the problem.
I'm guessing you're using XMLHttpRequest or fetch() on the frontend?
And hitting he URL that performs the redirect?
how i change code server-side?
Let's back up.
As I mentioned above there are two different ways to fix this. You can modify the server-side code or you can modify the client-side code. Did you write the code on both ends or just one?
Okay, so do you want to modify your server-side code or your client-side code to fix this?
i want to fix on server-side
Okay, so what is your client-side code expecting to get? Right now your server is redirecting to the Checkout URL, but your client-side code is not expecting that. In order to fix this on the server end can you explain what your client-side code is trying to do?
I put a form to capture customer data.
Enfermeras en Canadá - Guío enfermeros latinos que estén interesados en Canadá
there is a button that makes the request to the PHP file
That button doesn't work until I fill out the form, and I can't read the language so I don't know what to fill out. Can you share just the part of the code that handles that button being pressed?
<button id="checkout-button" type="submit" class="btn btn-dark btn-modern w-100 text-uppercase bg-color-hover-primary border-color-hover-primary border-radius-0 text-3 py-3">
<span id="button-text">Registrarse y Pagar <i class="fas fa-arrow-right ms-2"></i></span>
</button>
There's no JavaScript involved?
The CORS error you're getting indicates JavaScript is causing the problem.
<form role="form" class="contact-form-recaptcha-v3 needs-validation" method="POST" action="php/conferencia-checkout-form.php">
That's not JavaScript. The CORS error indicates JavaScript is trying to fetch that form URL. You don't know which JavaScript is doing that?
I use third party libraries.
Are you using a library that makes your page act like a single page application?
Maybe something like Turbolinks or something?
You are?
Okay, so if you remove that and it solves the problem you may be able to configure that library to ignore that particular URL.
Awesome!
thank you very much for your time. the problem was recaptcha