-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
401 Unauthorized #93
Comments
Did you use the correct APP URL on your .env? |
Same here! |
Also having the same issue - actually not working locally. Just getting a 401 as well. I have Any thoughts on anything obvious I might be missing? I also set the model to a different namespace |
i'm sorry.. i cant remember what i've done to make it work. But, i will try to remember and i come back here. It was a stupid thing. |
@hipoagencia thanks for taking some time to think through. I'm at a loss here haha. |
Ok, so I removed the $generator = new LoginUrl($user);
// $generator->setRedirectUrl('/account');
$url = $generator->generate(); Any thoughts on why this would be the case? |
I've also noticed that the URL defaults to |
I was having the same issue, but sorted it out. I'm using docker (laravel sail) with nginx & ssl and was using The right way is to update protected $proxies = '*'; after making this change, the signed urls are generated properly. |
Facing the 401 unauthorized error now, it was working well until it isn't working. This is the generated url:
In localhost it logs a user in, but redirects to '/' instead of to the redirect route and in production keep getting the 401 - unauthorized error. Any ideas or help is highly appreciated. |
Hi there, We’re participating in a hackathon, and we were on the verge of tears because the magic link authorization wouldn’t work in production. Our production website is deployed using Coolify, with an Nginx proxy and Traefik on top. On Cloudflare, we had Strict SSL enabled to ensure that only HTTPS traffic flows between Cloudflare and Traefik. The first step towards fixing the issue was to disable forceScheme. Disabling it allowed us to uncover the real problem behind URL generation. However, after disabling forceScheme, mixed content began to appear, breaking the entire app instead of just causing the 401 error during authentication. We explored different solutions for configuring trusted proxies, including one that fetched Cloudflare IP addresses to build the allow list dynamically. The key issue that we overlooked from the beginning was how the trusted proxies setup works. Trusted proxies allow specific HTTP headers (e.g., X-Forwarded-For and X-Forwarded-Proto) to override URL generation based on the protocol used in the outer proxy (in this case, HTTPS). To debug, we went into the container and created a public script to check the phpinfo() output. It’s crucial to check the phpinfo() output using an HTTP request, not through the CLI. Our problem was that the first proxy (Nginx, in our Nixpacks setup) was not forwarding the correct HTTP headers from the outer proxy, which originated from Cloudflare. If the X-Forwarded-Proto header doesn’t reach PHP, the trusted proxy setup won’t work. To fix this, we added the following lines to our Nginx configuration to ensure all necessary HTTP headers are forwarded:
With this configuration, phpinfo() began showing https in the X-Forwarded-Proto header. Afterward, we set up the trusted proxies with the correct IP addresses. In our case, the incoming IP address was Traefik’s, not a Cloudflare IP. This meant that when we initially added the Nginx configuration but continued using the Cloudflare middleware, it still didn’t work. Key takeaways (TL;DR):
We were ready to abandon our entire Coolify setup to bypass this problem, but after giving it a fifth try, we finally identified the root cause. |
I did a setup as mentioned in the readme, it works fine on local, but when i deploy on production, it gives a 401 Unauthorised error on
/magic-url/1?expires=1661899121&redirect_to=portal&user_type=app-models-user&signature=xxx
The text was updated successfully, but these errors were encountered: