Alpine.js button from standard Laravel Breeze package not working in prod

The weird thing is that it works perfectly locally. But in production https://manul-shop-production.up.railway.app/profile (you can login under b@b email using 'bbbbbb' password) it doesn't. "Delete account" button. Here is the code: <x-danger-button class="btn btn-danger" x-data="" x-on:click.prevent="$dispatch('open-modal', 'confirm-user-deletion')" >{{ __('Delete Account') }}</x-danger-button> <x-modal name="confirm-user-deletion" :show="$errors->userDeletion->isNotEmpty()" focusable> .......some code </x-modal> Other buttons on this page using alpine.js work both locally and in production... But this one does nothing in production...
39 Replies
Percy
Percy2y ago
Project ID: 55b60c33-a3b7-4eb2-b9a5-29ec31b81552
Maremarsik
MaremarsikOP2y ago
55b60c33-a3b7-4eb2-b9a5-29ec31b81552
Brody
Brody2y ago
sorry this isn't really a problem with railway, you will have to do some debugging to see what you have done differently with this button Vs the other buttons
Maremarsik
MaremarsikOP2y ago
I am trying but the thing that bugs me is that it works locally...
Brody
Brody2y ago
unfortunately that does not automatically mean its an issue with railway
Maremarsik
MaremarsikOP2y ago
So it's hard even to debug. Am I supposed to deploy every little change to see if it solved the issue? Quite annoying
Brody
Brody2y ago
nope you are supposed to install nixpacks and docker on your computer to build and run the docker images locally
Maremarsik
MaremarsikOP2y ago
I'm trying to build an image with nixpacks and bumping into
Error: Writing app Caused by: Permission denied (os error 13)
Can't find info in official docs on it, neither google anything...
Brody
Brody2y ago
you dont have permission to write to wherever you are writing to
Maremarsik
MaremarsikOP2y ago
should have prefixed with 'sudo'... going further! So, executing of 'nixpacks build' command outputted in docker image. But when I try to launch it:
SQLSTATE[08006] [7] connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections? connection to server at "localhost" (::1), port 5432 failed: Cannot assign requested address Is the server running on that host and accepting TCP/IP connections? (Connection: pgsql, SQL: select tablename, concat('"', schemaname, '"."', tablename, '"') as qualifiedname from pg_catalog.pg_tables where schemaname in ('public'))
Brody
Brody2y ago
do you have a database running locally?
Maremarsik
MaremarsikOP2y ago
yes
Brody
Brody2y ago
then you aren't using the right credentials or variables
Maremarsik
MaremarsikOP2y ago
but they work for me. When I run my app locally - I can interact with my DB using these credentials. Here they are (in my .env file) DB_CONNECTION=pgsql DB_HOST=localhost DB_PORT=5432 DB_DATABASE=ecommerce DB_USERNAME=marre DB_PASSWORD=***
Brody
Brody2y ago
might wanna look into internal networking with a dockerfile
Maremarsik
MaremarsikOP2y ago
could you please elaborate a bit? Thanks for your help, btw As far as I get it, there is no dockerfile if I use nixpacks build command
Brody
Brody2y ago
well there is a dockerfile made at one stage, but the output is an image, that you then run with docker https://stackoverflow.com/a/24326540
Maremarsik
MaremarsikOP2y ago
running sudo docker run -it manul-shop --network="host" helped, it started the app from a container!
Brody
Brody2y ago
perfect
Maremarsik
MaremarsikOP2y ago
So, now we can return to the original question. Now the button WORKS AGAIN, when I run the app from docker! Doesn't it mean that this is the Railway issue, for all that?
Brody
Brody2y ago
lmfao no I'm sorry but your button not working is not specifically railways fault is this extremely bizarre? yes do I know why it's happening? unfortunately not but I do know that this is not a railway specific issue do you get any cors errors? any console errors? anything to go off of?
Maremarsik
MaremarsikOP2y ago
No, nothing at all... Anyway, at least I got some basic knowledge of using Docker)
Brody
Brody2y ago
is an onclick event even registered for that particular button?
Maremarsik
MaremarsikOP2y ago
As far as understan (quite little) alpine.js, this: x-on:click.prevent is called a registering of a onclick event for a button...
Brody
Brody2y ago
just but does the browser see an on click event being registered
Maremarsik
MaremarsikOP2y ago
It seems so
Brody
Brody2y ago
that doesn't prove anything
Maremarsik
MaremarsikOP2y ago
I've got close to zero experience with alpine.js,, so it's really hard to debug... Maybe I shall place all attributes of this button in a single line?.. It's annoying that obviously I shall use trial and error method to find what's wrong, but this is very cumbersome 'cause I need to deploy the whole project every time to see the result.
Brody
Brody2y ago
and there really isn't any errors anywhere?
Brody
Brody2y ago
this is a "dropdown"
Brody
Brody2y ago
Maremarsik
MaremarsikOP2y ago
Hey man! I'm telling you - something is wrong with Railway in this case. Some variable treating alpine.js there is set differently, or something... So - I followed your advise, went through this alpine.js basic tutorial and completely refactored my code (along the way finding and fixing one more bug). But IT' STILL DOESN'T WORK PROPERLY on RAILWAY! Now the lower section is always expanded and never collapses! Though, again, locally it works as charm! https://manul-shop-production.up.railway.app/profile (you can login under b@b email using 'bbbbbb' password) <div x-data="{ open: {{ $errors->userDeletion->isNotEmpty() ? 'true' : 'false' }} }"> <x-danger-button class="btn btn-danger" x-on:click="open = ! open"> {{ __('Delete Account') }} </x-danger-button> <div x-show="open" @click.outside="open = false"> <form method="post" action="{{ route('profile.destroy') }}"> @csrf @method('delete') <p style="margin-top:1em"> {{ __('Please enter your password to confirm you would like to permanently delete your account.') }} </p> <div class="form-group" style="margin-bottom:10px"> <x-text-input id="password" name="password" type="password" class="form-control" placeholder="{{ __('Password') }}" /> <x-input-error :messages="$errors->userDeletion->get('password')" class="mt-2" /> </div> <div class="form-group"> <x-secondary-button x-on:click="open = false"> {{ __('Cancel') }} </x-secondary-button> <x-danger-button x-on:click="open = true" class="btn btn-danger"> {{ __('Delete Account') }} </x-danger-button> </div> </form> </div> </div>
Brody
Brody2y ago
honestly I am out of ideas, but I really do wanna help you, could you provide me with a repo for your code, and possibly a database dump of your database so I can test myself?
Maremarsik
MaremarsikOP2y ago
Surely! Thanks a lot for the attention!
Maremarsik
MaremarsikOP2y ago
GitHub
GitHub - Marre-86/manul-shop
Contribute to Marre-86/manul-shop development by creating an account on GitHub.
Maremarsik
MaremarsikOP2y ago
There are seeders for the database included
Brody
Brody2y ago
okay I'm out right now, but will take a crack at this later it looks like alpine.js inst being included in the profile page's js bundle
Maremarsik
MaremarsikOP2y ago
didn't get what you mean. Alpine.js is included to all pages of the app in the main layout where I write: @vite(['resources/js/app.js', 'resources/scss/app.scss'])
Brody
Brody2y ago
im sorry im out out of ideas then
Want results from more Discord servers?
Add your server