jeffroche / nextjs-django-auth-example Goto Github PK
View Code? Open in Web Editor NEWExample of integrating Next.js with a Django API
Home Page: https://nextjs-django-auth-example.vercel.app
Example of integrating Next.js with a Django API
Home Page: https://nextjs-django-auth-example.vercel.app
I have followed your schema to implemente auth in my web. All seemed to be working good, but I noticed it was hanging my browser after been logged for some minutes. I have debugged and I found that sometimes (I couldn't find a fixed pattern) when the token gets refreshed, the auth library gets stuck in an infinite loop related to the "loading" state variable.
// Returns an access token if there's one or refetches a new one
console.log("Getting access token..");
if (accessTokenIsValid()) {
console.log("Getting access token.. existing token still valid");
return Promise.resolve(accessToken);
} else if (loading) {
while (loading) {
console.log("Getting access token.. waiting for token to be refreshed");
}
// Assume this means the token is in the middle of refreshing
return Promise.resolve(accessToken);
} else {
console.log("Getting access token.. getting a new token");
const token = await refreshToken();
return token;
}
}
It happens on this while loop, lines 158-160 on auth.tsx. I have tried a lot of things, but none have worked. The only thing I could do for "a quick fix" is to delete this else if clause, but I have some unauthorized requests then.
Is there any way to get the authentication to persist past a page refresh? Or is it supposed to, and I have something configured wrong? Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.