cms icon indicating copy to clipboard operation
cms copied to clipboard

migrated to Auth.js v5 from nextAuth and Edge runtime compatibility fixes

Open ankitmukhia opened this issue 1 year ago • 1 comments

Title

"Migrated to Auth.js v5 from NextAuth and Edge Runtime Compatibility Fixes"

Problem Description

  1. Outdated NextAuth.js Version
    • The project was using an old version of next-auth, incompatible with the new designs folder structure. This caused issues with authentication flows and required updates to middleware and session management.
  2. Bcrypt Incompatibility with Edge Runtime
    • bcrypt was incompatible with the Edge runtime, leading to errors due to its reliance on native Node.js modules. More details can be found in this [GitHub issue](https://github.com/kelektiv/node.bcrypt.js/issues/1017).
  3. ORM compt
  • Traditional ORMs had issues running in the Edge runtime

Solution

  1. Migration to Auth.js v5
    • Upgraded to authjs v5.
    • Refactored folder structure to align with the new design.
    • Implemented necessary middleware and updated session management to use the new universal methods.
  2. Replacing Bcrypt
    • Switched from bcrypt to an Edge-compatible alternative like bcryptjs.
    • And added nw login form.
  3. edgee-Compatible
  • splited authentication config into separate files. this change ensures that we use a session strategy that’s compatible with the edge environment,

ankitmukhia avatar Aug 19 '24 20:08 ankitmukhia

@ankitmukhia the PR is adding 11k+ lines and deleting many lines of code. I am also getting a similar issue in which I only changed one file, but when opening a PR it shows that I changed 10 files and added many lines. However, the other code is from someone else. How can I fix this? Do you have any ideas?

itzamanjain avatar Aug 20 '24 04:08 itzamanjain