Ecommerce Shopify WordPress Discussion

Django CSRF token not saving to browser cookies in Production environment, but working in Development environment

We have created a Django application to create a Shopify Application. We are having issues with out production environment we AJAX calls to the Django application are failing because the CSRF token is not being saved to cookies and therefore nothing gets parsed in the AJAX call headers. We have followed the Django documentation and added {% csrf_token %} in the <head> tag of our base.html file which all other html files reference. I have also tried to add the following into <head> tag: <script> var csrf_token = '{{ csrf_token }}'; </script> My AJAX call looks like: $.ajax({ url: url, type: 'GET', dataType: 'json', method: 'POST', headers: { 'X-CSRFToken': csrf_token, 'X-Shopify-Domain': shopifyDomain }, mode: 'same-origin', success: function(data) { resolve(data); }, error: function(xhr, status, error) { console.error(`Error in ${url}:\nStatus: ${xhr.status}\nError: ${error}\nResponse: ${xhr.responseText}`); reject(new Error(`Error in ${url}: ${xhr.responseText}`)); } }); Because this is a Shopify App, this app is embedded into a iFrame in Shopify but I am not sure this is the culprit as its the same in our development environment. Production Application in is Azure App Service and behind a Azure Front Door, not sure if this is causing any issues. There does seem to be cookies in the browser from our domain, just not the csrf token: We can't find a solution to why this is happening. We have had to mark our functions dispatch with @csrf_exempt which we don't want to have to do moving forward. For example: @csrf_exempt def dispatch(self, *args, **kwargs): return super().dispatch(*args, **kwargs)
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.