Closed hardikpanotmc closed 2 years ago
Most likely you have not disabled CSRF, that is why you are getting 419. https://github.com/osiset/laravel-shopify/wiki/Installation#csrf
Same issue When i has upgrade 16.0.0 to latest v(17.1.1) all Ajax request return the error [ {error: "Session token is invalid."} error: "Session token is invalid."].
@khaiknievel CSRF already disabled
@beingak You might want to refer to this #895. Also the upgrading guide.
@khaiknievel
I try to this
axios.interceptors.request.use(function (config) {
return utils.getSessionToken(window['app-bridge-app']) // requires a Shopify App Bridge instance
.then((token) => {
console.log('axios token');
// Append your request headers with an authenticated token
config.headers.Authorization = Bearer ${token}
;
return config;
});
});
But it not working from me
I have simple AJAX request.
$.ajax({
type: 'GET',
dataType: 'JSON',
url: ${window.location.origin}/app/fetch-messages
,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'X-CSRF-Token': csrfToken,
'shop': 'aruntesting1.myshopify.com'
},
success: (data)=> {
if(data.status) $('#dashboard-fetch-message').empty().html(data.html);
},
error: (xhr, textStatus, errorThrown) => console.log(xhr.statusText)
});
Can you please let me know. How i can use this.
Hello, I have HTML + Laravel (Shopify app). I am doing get and post Ajax request. which has been request to web.php middleware route. it did return [ 302 ] status. [ {error: "Session token is invalid."}]
Do can you let me know how can i get the valid session token and how could be use into Ajax request.Please add example.
Might be helpful #1083
This sounds like an issue with your code setup, not the app so closing as a couple solutions have been provided.
Expected Behavior
Ajax post/get method returns a success message. POST routes send data securely. Session/Flash message or data pass and store in session or flash.
Current Behavior
Ajax returns 302 status code and error. POST routes are returning 419. if we store any data in session or flash is not get in another place of code.