fritsvt / laravel-nuxt-authentication

Local and social authentication boilerplate using Laravel + Nuxt
72 stars 33 forks source link

500 Error on http://localhost:3000/auth/register page #4

Closed connecteev closed 5 years ago

connecteev commented 5 years ago

After installation I see this error in the console:

VM136:1 OPTIONS http://jwt-auth.test/api/me 404 (Not Found)
(anonymous) @ VM136:1
dispatchXhrRequest @ commons.app.js:434
xhrAdapter @ commons.app.js:273
dispatchRequest @ commons.app.js:881
Promise.then (async)
request @ commons.app.js:683
wrap @ commons.app.js:1226
request @ app.js:560
requestWith @ app.js:593
_callee3$ @ app.js:1100
tryCatch @ commons.app.js:6471
invoke @ commons.app.js:6697
prototype.<computed> @ commons.app.js:6523
asyncGeneratorStep @ commons.app.js:31
_next @ commons.app.js:53
(anonymous) @ commons.app.js:60
(anonymous) @ commons.app.js:49
fetchUser @ app.js:1115
fetchUser @ app.js:418
fetchUserOnce @ app.js:539
mounted @ app.js:979
mounted @ app.js:369
_callee$ @ app.js:288
tryCatch @ commons.app.js:6471
invoke @ commons.app.js:6697
prototype.<computed> @ commons.app.js:6523
asyncGeneratorStep @ commons.app.js:31
_next @ commons.app.js:53
(anonymous) @ commons.app.js:60
(anonymous) @ commons.app.js:49
init @ app.js:322
(anonymous) @ app.js:911
_callee2$ @ app.js:3940
tryCatch @ commons.app.js:6471
invoke @ commons.app.js:6697
prototype.<computed> @ commons.app.js:6523
asyncGeneratorStep @ commons.app.js:31
_next @ commons.app.js:53
Promise.then (async)
asyncGeneratorStep @ commons.app.js:41
_next @ commons.app.js:53
Promise.then (async)
asyncGeneratorStep @ commons.app.js:41
_next @ commons.app.js:53
Promise.then (async)
asyncGeneratorStep @ commons.app.js:41
_next @ commons.app.js:53
Promise.then (async)
asyncGeneratorStep @ commons.app.js:41
_next @ commons.app.js:53
(anonymous) @ commons.app.js:60
(anonymous) @ commons.app.js:49
_createApp @ app.js:4011
createApp @ app.js:3755
(anonymous) @ app.js:2007
./.nuxt/client.js @ app.js:2973
__webpack_require__ @ runtime.js:796
fn @ runtime.js:151
0 @ app.js:6489
__webpack_require__ @ runtime.js:796
checkDeferredModules @ runtime.js:46
webpackJsonpCallback @ runtime.js:33
(anonymous) @ app.js:1
Show 7 more frames
register:1 Access to XMLHttpRequest at 'http://jwt-auth.test/api/me' from origin 'http://localhost:3000' 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.

Which led me to find and replace 'http://jwt-auth.test' in client/nuxt.config.js with my Laravel app's URL (http://localhost:8000 in this case):

  axios: {
    // See https://github.com/nuxt-community/axios-module#options
    baseURL: "http://localhost:8000/api"
  },

Then, when I go to http://localhost:3000/auth/register I see this error in the console:

GET http://localhost:8000/api/me 500 (Internal Server Error)

{,…}
exception: "Symfony\Component\Debug\Exception\FatalThrowableError"
file: "/Users/kunalpunjabi/Code/LARAVEL_WORKING_CODE/SSR/NUXT/laravel-nuxt-authentication/vendor/lcobucci/jwt/src/Signer/Hmac.php"
line: 29
message: "Argument 3 passed to Lcobucci\JWT\Signer\Hmac::doVerify() must be an instance of Lcobucci\JWT\Signer\Key, null given, called in /Users/kunalpunjabi/Code/LARAVEL_WORKING_CODE/SSR/NUXT/laravel-nuxt-authentication/vendor/lcobucci/jwt/src/Signer/BaseSigner.php on line 42"
trace: [{,…}, {,…}, {,…}, {,…}, {,…}, {,…}, {,…}, {,…}, {,…}, {,…}, {,…}, {,…}, {,…}, {,…}, {,…}, {,…}, {,…},…]

At this point I'm completely stuck..any ideas how to proceed?

fritsvt commented 5 years ago

because you didn't generate a jwt secret. runphp artisan jwt:secret

connecteev commented 5 years ago

Thank you, a lot is still missing from the Readme / installation instructions. I'll submit a PR with detailed documentation.