Closed cavitznky closed 2 months ago
@izsoft I've never used Livewire, so I don't know the answer to this one sadly.
I'll leave it open and add the help wanted tag, so someone else who also used Livewire might be able to assit.
Thank you for your answer @Kyon147,
I hope there are friends who have solved this problem for Livewire v3 and I would appreciate if they can help.
By the way, the code I mentioned in the first message works on Livewire v2. So for Livewire v3 it is also necessary to add a token to each request. But I couldn't find how to do it.
Yes, it's possible:
if (Livewire) {
Livewire.hook('request', ({options}) => {
options.headers['Authorization'] = `Bearer ${window.sessionToken}`;
options.headers['Content-Type'] = 'application/json';
options.headers['X-Requested-With'] = 'XMLHttpRequest';
});
}
@d-shannon I have added livewire in our app and added, javascript code in the header but it is still not working.
here is the issue: https://www.awesomescreenshot.com/video/24223426?key=3f47b3eb8e254c6d596ea7c81e56d9f9
The auth user is not showing after the livewire update.
Please suggest me if you have any solution. Thanks in advance.
@cyberkishor This is just a guess as I't not worked with Livewire but check your AppBridge object and see if it still has the right info and that host
is being passed into it with the stores details.
9 times out of 10 - user being lost between pages or transitions is because of the host
param being lost so appbridge can reinit.
@Kyon147 The AppBride is ok and it's past the correct host, the issue is inside the Livewire config or something.
If I have some time this week one evening I'll try and spin up a quick test and see if I can see the issue
Had a look this weekend but not jump out at me yet, so need to do some more digging but will let you know
@izsoft It appears that the middleware setting is no longer present in the Livewire 3 configuration file. As a result, the 'verify.shopify' middleware was not applied in my case.
I resolved this issue by adding the following code to AppServiceProvider to ensure that the middleware is applied.
Livewire::setUpdateRoute(function ($handle) {
return Route::post('/livewire/update', $handle)
->middleware(['verify.shopify']);
});
Greetings,
Thank you for your support.
As @d-shannon said, the token_handler blade file needs to be updated.
Also as @donkooijman said or as I mentioned below, you need to specify the middleware in the service providers.
Livewire::addPersistentMiddleware(VerifyShopify::class);
@Kyon147
Yes confirming @izsoft comment. I updated the token_handler and applied the persistent middleware.
Great work all, can someone create a PR for this? It will allow others to use Limewire v3 if they wish or we can add the steps into the wiki.
I created a PR with based on @d-shannon comment with an updated token_handler blade file
This is the PR #286 for ref
I'm having trouble getting livewire to work. I've added this to the app service provider
Livewire::setUpdateRoute(function ($handle) {
return Route::post('/livewire/update', $handle)
->middleware(['verify.shopify']);
});
Livewire::addPersistentMiddleware(VerifyShopify::class);
I've also added the changes in your PR. But livewire isn't making any round trips to the server. I can confirm the livewire styles and script is being loaded. But even AlpineJS isn't working. Any ideas?
Closing this issue as it is getting too long with other issues. Please open new issues if needed.
Hi everyone,
I want to develop an application with Laravel-livewire v3 but the following code is not working.
When I checked, there is no addHeaders method in v3.
How can I solve this?
inside the ('shopify-app::partials.token_handler') file
@Kyon147