1

I have a Craft instance running via Valet, per the instructions here.

Running the project via valet link works great, and valet share works, except when I try to access the admin side. I'm using valet share to try to access the site over a local network for a demo.

In Chrome from http://ad3f5068.ngrok.io/admin/login when I try to log in, I get:

OPTIONS http://craftycoffee.test:60/index.php?p=admin/actions/users/login 404 (Not Found)
Access to XMLHttpRequest at 'http://craftycoffee.test:60/index.php?p=admin/actions/users/login' from origin 'http://ad3f5068.ngrok.io' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

If I use HTTPS, I get net::ERR_SSL_PROTOCOL_ERROR across a bunch of requests.

What am I missing to get this to share over a local host?

2

I'm not 100% sure this is the answer to your issue; but this might be the solution:

Helge has written an article here about using ngrok with Craft CMS (which I'd recommend looking over if you haven't already). In particular, he mentions he has the following lines in his Craft config particularly for logging into the CP over ngrok:

// Logging in to the CP will fail unless you turn off CSRF protection.
'enableCsrfProtection' => false,

Try that config option and see if that fixes the issue for you...

  • Thanks for the suggestion. I tried it out, and this does not fix it. – BBaysinger Apr 1 at 20:19
  • I found the note in your tutorial that says Craft needs unsecured to run admin on valet share. Is CSRF protection the only thing that needs addressed for that? – BBaysinger Apr 1 at 21:03
  • That actually has changed recently; thanks to this PR we can now share secured sites as easily as unsecured ones. Let me test one of my own sites and see if I can login over ngrok... – Jalen Davenport Apr 2 at 12:27
  • Thank you. Any luck on that? – BBaysinger Apr 8 at 22:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.