SohoHouse / nuxt-oauth

Simple OAuth2 integration for your Nuxt app
MIT License
122 stars 27 forks source link

Cannot read property 'match' of undefined #32

Closed ntallapa12 closed 5 years ago

ntallapa12 commented 5 years ago

I am getting the below error when trying to integrate next-oauth into my nuxt project, Below is the stack trace

(node:86432) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'match' of undefined at normalize (/Users/ntalla/Acxiom/git_repo/personal/factly/dega-web/node_modules/url-join/lib/url-join.js:11:21) at /Users/ntalla/Acxiom/git_repo/personal/factly/dega-web/node_modules/url-join/lib/url-join.js:70:12 at Handler.createAuth (/Users/ntalla/Acxiom/git_repo/personal/factly/dega-web/node_modules/nuxt-oauth/lib/handler.js:33:23) at Handler.init (/Users/ntalla/Acxiom/git_repo/personal/factly/dega-web/node_modules/nuxt-oauth/lib/handler.js:16:20) at new Handler (/Users/ntalla/Acxiom/git_repo/personal/factly/dega-web/node_modules/nuxt-oauth/lib/handler.js:8:8) at /Users/ntalla/Acxiom/git_repo/personal/factly/dega-web/node_modules/nuxt-oauth/lib/server-middleware.js:17:19 at

Any help is highly appreciated

cedricium commented 5 years ago

+1, seeing this as well and have no idea what the issue is. I followed the setup outlined in the README word-by-word.

EDIT: figured out what the issue was. I was using the @nuxtjs/dotenv package to load my env variables. However, because we need process.env. variables at build-time, you also need to include require('dotenv').config() at the top of your nuxt.config.js file.

Source: https://github.com/nuxt-community/dotenv-module#using-env-file-in-nuxtconfigjs

samtgarson commented 5 years ago

I think @cedricium's solution is an acceptable one.

If you're building an SPA remember not to build your client secret into the client side bundle.