405 Error on Login

Following methodology in your book, everything running great, woke up this morning and now I can’t login locally - getting a 405 error because Nuxt is trying to run a “GET Method” instead of Post…

Why would this be happening all of a sudden?

Also, is it strange to have this many requests with a single login attempt?

Screen Shot 2020-09-27 at 12.18.18 PM

And it looks like some Chrome update (it works fine in Firefox)…

Do you have any information on how you setup your local environment? I could never figure out how to run Nuxt through https - and I’m pretty sure this is the error I’m getting this morning.

I can easily switch the API server with valet, but with Nuxt, I could never get it to run https.

UPDATE: got it to start working again by disabling web security which is less than ideal, but gets me past the original roadblock for now

Hi @jhull,

That’s super bizarre that it just switched to GET. The method is set in your nuxt.config.js file but if you are using Laravel Sanctum with the laravelSanctum auth strategy, it should automatically POST to the /login route.

With the multiple requests to the /login route and /csrf-cookie route, I assume 1 is the OPTIONS request and the other is the actual request. However, I don’t know why there are 3. Are you by any chance hooking into the method to submit the log in form multiple times? Like 2 event handlers? Just throwing out some possible ideas.

As for running NuxtJS locally with HTTPS, we did get it working. However, we have a Docker development environment that @jaydrogers set up custom. He can guide a little more on the HTTPS side of things, I know it was kind of a trick.

Hi @jhull,

You can enable a self-signed HTTPS for local development here: https://nuxtjs.org/api/configuration-server/

You can create your own certificates using OpenSSL: http://www.programmers-code.org/2019/02/19/how-to-create-a-self-signed-certificate-on-mac-os/

You’ll notice that we have a self-signed key-pair for development in the root of our repo: https://gitlab.com/serversideup/roast/roast-frontend

You could even use those keys if you wanted.

What about running in production?

That’s a book in itself :grinning:

Basically what we do is run a custom certificate on the docker container that is proxied to Traefik (which handles the edge certificates automatically for us with Let’s Encrypt)

This way the entire connection is terminated over SSL using a free signed certificate.

Let me know if you have any questions. I hope this helps!

OK…trying it again…

Made my own, didn’t work. Grabbed yours and put them in the root of the app, added those keys into nuxt.config.js, ran yarn dev and it says it’s listening on https://localhost:3000 but going there, I get “Connection is not private NET::ERR_CERT_AUTHORITY_INVALID”

I’ve never been able to get to this work! :rofl:

Here’s much better instructions (sorry) https://stackoverflow.com/questions/7580508/getting-chrome-to-accept-self-signed-localhost-certificate

You need to create a Certificate Authority, then have your key pair created (signed by your own Certificate Authority).

I will DM you our CA certificate as well (in case you want to just use ours for your development) so your computer will trust the certificate we have.

Hello,

Is there an updated URL? This one does not seem to work anymore.

Thank you!

The link loads for me:

It is a private repository and you are granted immediate access on purchasing the complete package of our book: https://serversideup.net/ultimate-guide-to-building-apis-and-spas-with-laravel-and-vuejs/