Help with Next.js Login Implementation Using Cloudflare Pages and D1 Database

Is there a template i can follow i feel like my code is correct but my login functionality is not working correctly.
4 Replies
Chaika
Chaika3w ago
?account-recovery
Flare
Flare3w ago
These links may help, but they only work when logged out. You can always use an Incognito Window or a Private Window to ensure you're logged out. If you know the email: https://dash.cloudflare.com/forgot-password If you know the email and have 2FA or email delivery issues: https://dash.cloudflare.com/login-help If you don’t know the email: https://dash.cloudflare.com/forgot-email
Chaika
Chaika3w ago
@Eric Raymond ^ If you're having login issues, try login-help, is that your question?
Eric Raymond
Eric RaymondOP3w ago
Hi everyone, I'm currently building a Next.js application hosted on Cloudflare Pages with a D1 database, and I’m facing a few challenges with implementing the login functionality. Here’s a breakdown of the issues I’m encountering: TypeScript Type Errors: I’ve defined interfaces for login responses and user data in src/types/api.ts, but I’m receiving type errors during the build process. The main issue is that TypeScript doesn’t seem to recognize the shape of the response.json() data when handling the login API response in my login page component. Best Practices for Authentication: I’ve set up the database structure for user authentication in D1, including tables for users, tokens, and sessions. However, I’m unsure if my login flow implementation adheres to best practices, especially in terms of security and scalability. What I’ve Done So Far: Centralized API type definitions in src/types/api.ts to ensure consistent typing across the application. Implemented error handling for login responses, including server-side validation for user credentials. Set up user validation logic at the database level to ensure accurate login credentials. What I’m Looking For: Review of My Approach: Feedback on whether my login implementation and database structure are correct and follow industry best practices. Best Practices: Suggestions for managing authentication with Cloudflare Pages and D1, particularly for a Next.js application. TypeScript Guidance: Tips on defining and handling TypeScript types for API responses, especially when dealing with response.json() and dynamic response shapes. If anyone has experience with a similar stack or can recommend a good example/template to follow, I’d really appreciate your insights. Thanks in advance for your help!
Want results from more Discord servers?
Add your server