You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encountered an issue while developing my latest project. The frontend is hosted at example.com, while the backend is at api.example.com. Due to the different domains, the browser automatically sends an OPTIONS request for CORS.
Since this is done automatically by the browser, we are unable to set the woocommerce-session header. As a result, a new session is created in the wp_woocommerce_sessions table for each OPTIONS request.
To prevent this issue, I believe it would be better to check if the request method is not OPTIONS before creating a session.
The image below illustrates the unnecessary tokens that are being created.
To Reproduce
Simply call services from a localhost to any backend multiple times. Even though we set the woocommerce-session header, there is nothing we can do for the OPTIONS requests.
If you agree, I can implement the necessary changes myself and submit a pull request.
Thank you!
The text was updated successfully, but these errors were encountered:
pooriaset
changed the title
CORS Issue with WooCommerce Sessions
Preventing Unwanted WooCommerce Sessions from Automatic OPTIONS Requests
Nov 29, 2024
Describe the bug
Hello,
I encountered an issue while developing my latest project. The frontend is hosted at
example.com
, while the backend is atapi.example.com
. Due to the different domains, the browser automatically sends an OPTIONS request for CORS.Since this is done automatically by the browser, we are unable to set the woocommerce-session header. As a result, a new session is created in the wp_woocommerce_sessions table for each OPTIONS request.
To prevent this issue, I believe it would be better to check if the request method is not
OPTIONS
before creating a session.The image below illustrates the unnecessary tokens that are being created.
To Reproduce
Simply call services from a localhost to any backend multiple times. Even though we set the woocommerce-session header, there is nothing we can do for the
OPTIONS
requests.If you agree, I can implement the necessary changes myself and submit a pull request.
Thank you!
The text was updated successfully, but these errors were encountered: