Skip to content
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 issue when trying to deploy using CLI #292

Closed
saikksub opened this issue Sep 23, 2024 · 5 comments
Closed

401 - Unauthorized issue when trying to deploy using CLI #292

saikksub opened this issue Sep 23, 2024 · 5 comments

Comments

@saikksub
Copy link

Describe the bug
Unable to deploy application using NuxtHub CLI

Steps to reproduce
Steps to reproduce the behavior:

  1. Create an empty project from Admin NuxtHub Console.
  2. Create a basic nuxt project
  3. Setup nuxthub by following steps - https://hub.nuxt.com/docs/getting-started/installation#add-to-a-nuxt-project
  4. Use npx nuxthub deploy. This will automatically authenticates nuxthub by opening default browser.
  5. See error

Expected behavior

groogair ~/projects/IPHEC-Reports % nuxthub deploy
NuxtHub CLI                                                                                                                                                                                                               10:40:24 AM
ℹ Please login to deploy your project or set the NUXT_HUB_USER_TOKEN environment variable.                                                                                                                               10:40:25 AM
ℹ Please visit the following URL in your web browser:                                                                                                                                                                    10:40:26 AM
ℹ https://admin.hub.nuxt.com/api/cli/authorize?redirect=http:%2F%2Flocalhost:58683%2F                                                                                                                                    10:40:26 AM
ℹ Waiting for authentication to be completed...                                                                                                                                                                          10:40:26 AM
✔ Authenticated successfully!                                                                                                                                                                                            10:40:31 AM
ℹ No project is linked with the NUXT_HUB_PROJECT_KEY environment variable.                                                                                                                                               10:40:32 AM
│
◇  Deploy ~/projects/IPHEC-Reports to NuxtHub?
│  Yes

 ERROR  [GET] "https://admin.hub.nuxt.com/api/teams": 401  - Unauthorized                                                                                                                                                 10:40:34 AM

  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async $fetch2 (/Users/kiransaisubramanyamkalimisetty/.nvm/versions/node/v18.20.4/lib/node_modules/nuxthub/node_modules/ofetch/dist/shared/ofetch.4747642d.mjs:304:15)
  at async selectTeam (/Users/kiransaisubramanyamkalimisetty/.nvm/versions/node/v18.20.4/lib/node_modules/nuxthub/src/utils/data.mjs:34:17)
  at async Object.setup (/Users/kiransaisubramanyamkalimisetty/.nvm/versions/node/v18.20.4/lib/node_modules/nuxthub/src/commands/deploy.mjs:63:20)
  at async runCommand (/Users/kiransaisubramanyamkalimisetty/.nvm/versions/node/v18.20.4/lib/node_modules/nuxthub/node_modules/citty/dist/index.mjs:288:5)
  at async runCommand (/Users/kiransaisubramanyamkalimisetty/.nvm/versions/node/v18.20.4/lib/node_modules/nuxthub/node_modules/citty/dist/index.mjs:307:11)
  at async runMain (/Users/kiransaisubramanyamkalimisetty/.nvm/versions/node/v18.20.4/lib/node_modules/nuxthub/node_modules/citty/dist/index.mjs:445:7) 

 ERROR  [GET] "https://admin.hub.nuxt.com/api/teams": 401  - Unauthorized  
@atinux
Copy link
Contributor

atinux commented Sep 23, 2024

Sorry about this @saikksub

Could you upgrade nuxthub to v0.6.2 and run this command?

DEBUG=1 nuxthub deploy

And show me the error?

@GreenmeisterDavid
Copy link

Same issue, adding the debug gives this output;

david@MBP-van-David Greenmeister-Frontend-Hulk % DEBUG=1 npx nuxthub deploy
NuxtHub CLI                                                                                                                                                      11:47:26 AM
⚙ Fetching https://admin.hub.nuxt.com/api/user                                                                                                                  11:47:26 AM
⚙ Error when fetching https://admin.hub.nuxt.com/api/user                                                                                                       11:47:26 AM
ℹ Please login to deploy your project or set the NUXT_HUB_USER_TOKEN environment variable.                                                                      11:47:26 AM
⚙ Fetching https://admin.hub.nuxt.com/api/user                                                                                                                  11:47:26 AM
⚙ Error when fetching https://admin.hub.nuxt.com/api/user                                                                                                       11:47:27 AM
ℹ Please visit the following URL in your web browser:                                                                                                           11:47:27 AM
ℹ https://admin.hub.nuxt.com/api/cli/authorize?redirect=http:%2F%2Flocalhost:53940%2F                                                                           11:47:27 AM
ℹ Waiting for authentication to be completed...                                                                                                                 11:47:27 AM
⚙ Fetching https://admin.hub.nuxt.com/api/cli/verify                                                                                                            11:47:27 AM
⚙ Fetching https://admin.hub.nuxt.com/api/user                                                                                                                  11:47:27 AM
✔ Authenticated successfully!                                                                                                                                   11:47:27 AM
⚙ Fetching https://admin.hub.nuxt.com/api/user                                                                                                                  11:47:28 AM
⚙ Error when fetching https://admin.hub.nuxt.com/api/user                                                                                                       11:47:28 AM
⚙ Fetching https://admin.hub.nuxt.com/api/projects/greenmeister-fr-j3sk                                                                                         11:47:28 AM
⚙ Error when fetching https://admin.hub.nuxt.com/api/projects/greenmeister-fr-j3sk                                                                              11:47:29 AM
ℹ No project is linked with the NUXT_HUB_PROJECT_KEY environment variable.                                                                                      11:47:29 AM
│
◇  Deploy ~/Development/Greenmeister-Frontend-Hulk to NuxtHub?
│  Yes
⚙ Fetching https://admin.hub.nuxt.com/api/teams                                                                                                                 11:47:33 AM
⚙ Error when fetching https://admin.hub.nuxt.com/api/teams                                                                                                      11:47:33 AM

 ERROR  [GET] "https://admin.hub.nuxt.com/api/teams": 401  - Unauthorized                                                                                        11:47:33 AM

  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async $fetch2 (/Users/david/.npm/_npx/0fa85d1aa04cf089/node_modules/ofetch/dist/shared/ofetch.4747642d.mjs:304:15)
  at async selectTeam (/Users/david/.npm/_npx/0fa85d1aa04cf089/node_modules/nuxthub/src/utils/data.mjs:36:17)
  at async Object.setup (/Users/david/.npm/_npx/0fa85d1aa04cf089/node_modules/nuxthub/src/commands/deploy.mjs:63:20)
  at async runCommand (/Users/david/.npm/_npx/0fa85d1aa04cf089/node_modules/citty/dist/index.mjs:288:5)
  at async runCommand (/Users/david/.npm/_npx/0fa85d1aa04cf089/node_modules/citty/dist/index.mjs:307:11)
  at async runMain (/Users/david/.npm/_npx/0fa85d1aa04cf089/node_modules/citty/dist/index.mjs:445:7) 



 ERROR  [GET] "https://admin.hub.nuxt.com/api/teams": 401  - Unauthorized                                                                                        11:47:33 AM

Notice that this project is already deployed at NuxtHub, but suddenly it doesn't recognize the project key anymore (could this issue be related?) The project key 'greenmeister-fr-j3sk' is in my .env, and also is the correct one that I see on my nuxthub dashboard.

@atinux
Copy link
Contributor

atinux commented Sep 23, 2024

The error is coming from unjs/ofetch#436 as it normalizes the headers now, published a fix on [email protected], can you please upgrade and try again?

npx nuxthub@latest deploy

@franciscohermida
Copy link

franciscohermida commented Sep 23, 2024

managed to deploy again on 0.6.3 after having the same error as OP
thx

@GreenmeisterDavid
Copy link

Updated and everything runs smooth again. 💚

@atinux atinux closed this as completed Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants