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

Handle undefined OAuth token pools gracefully #19

Merged
merged 2 commits into from
Sep 29, 2024

Conversation

AntoineKM
Copy link
Contributor

Hi @harlan-zw,

Description

What did I change?

  • Modified the initialization of tokens and privateTokens in nuxt.config.ts - Now initializing as empty arrays ([]) instead of false when environment variables are not set.
  • Updated the condition for seeding main tokens - Now checks if the tokens array is empty (tokens.length === 0) instead of checking if it's falsy.
  • Left the rest of the Nuxt configuration unchanged.

Why did I change it?

  • To fix a runtime error: "privateTokens.map is not a function - This error occurred because privateTokens was sometimes false instead of an array.
  • To improve the robustness of the OAuth token handling: The code now gracefully handles cases where the OAuth pool environment variables are not set.
  • To ensure consistent behavior: By always working with arrays (even if empty), we prevent type-related errors and make the code more predictable.
  • To maintain functionality when environment variables are not set: The changes allow the application to run without errors, even if the OAuth pools are not configured, potentially falling back to default behavior.

Linked Issues

- initialize tokens and privatetokens as empty arrays when env vars are not set
- update token seeding logic to check for empty array instead of falsy value
- prevent 'privatetokens.map is not a function' error in Nuxt config
the .gitignore file was updated to include the .nuxt directory, which was previously not being ignored. this change ensures that the .nuxt directory is not tracked by git.
Copy link

vercel bot commented Sep 23, 2024

@AntoineKM is attempting to deploy a commit to the My Team Team on Vercel.

A member of the Team first needs to authorize it.

@harlan-zw
Copy link
Owner

Thanks!

@harlan-zw harlan-zw merged commit 2190142 into harlan-zw:main Sep 29, 2024
1 check failed
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

Successfully merging this pull request may close these issues.

2 participants