Redirection Problem / Google indexing. #136
-
Hello, So I have realized I have two problems currently on my website which use fief, which may be linked. The first problem is that at random times, mostly when it's been a while that i've connected on it, going in a page of my website after a while (especially the main page) sends me toward the "login" page defined in the auth_callback method. Because of the way I've implemented the login page it it leads to a blank page and nothing more happens.. I am not sure I suspect this started to appear since I've been using the "Cached Auth" method, and that it may happens when fief is somehow trying to refresh a token or something. Here's the code I use to define a page (I put the diff so you can see what was used before this happened): And the code of the fief functions:
( The implementation of the login is as such it enables refreshing a form in case the user wants to connect after having done a simulation, so login is always opened in a new window, then closed and the form is re-submitted automatically ) Also it's important to note that I've seen it happen recently, even after changing the times of the login and refresh token to a high value like 1 year. The second problem is that I have lost my indexing on google, and it says "page with redirect". Apaprently it happened starting as early as 9 august, which is after I added the cached auth. For all my website page, I have this on the google console: Do you have any clue of what is happening and what I should do to correct it ? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hi @arminvburren 👋 So, lot of things are going on here. I'll try to dig things one by one. The login endpointI understand that you're trying to open Fief's login page in another window with some JS code to avoid to lose data user may have input in the form. I'm not a big fan of this solution since it breaks a bit the redirection flow. IMO, I would suggest to revisit this so you store your form data reliably on the user browser. Something like LocalStorage looks like a good candidate: when the user makes change to the form, save it in the local storage. When the user opens the page, you can check if there is data in the LocalStorage and load it into the form. The nice thing with this solution is that it works for the login redirection, but also if your visitor comes to your site, leave and come back a few hours/days later. The token expirationIn the implementation of
That said, this should not be a big issue if you solve the previous point: redirections would make their work and you would be authenticated again without even noticing. Side noteFrom the tests I've made, it looks like your access token is still valid for only 24 hours, not a year. Are you sure you set the parameter correctly? Google ConsoleFrom what I see, I don't think this is a problem related to Fief. There is a few things that could explain that things go wrong:
So I would suggest to implement your sitemap using the XML format. You can even implement it with FastAPI and use **FastAPI Sitemap example**deployment_date = datetime.date.today()
@router.get("/sitemap.xml")
async def sitemap(request: Request):
urls = [
# Homepage
{
"loc": request.url_for("index"),
"lastmod": deployment_date,
"changefreq": "weekly",
"priority": 1.0,
},
# Accelerators
{
"loc": request.url_for("index"),
"lastmod": deployment_date,
"changefreq": "weekly",
"priority": 1.0,
},
]
# Generate list of urls
urls_xml = ""
for url in urls:
urls_xml += f"""
<url>
<loc>{url["loc"]}</loc>
<lastmod>{url["lastmod"].isoformat()}</lastmod>
<changefreq>{url["changefreq"]}</changefreq>
<priority>{url["priority"]}</priority>
</url>
"""
# Generate final sitemap
sitemap = f"""<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{urls_xml}
</urlset>
"""
return Response(content=sitemap, media_type="application/xml") |
Beta Was this translation helpful? Give feedback.
-
Hello, Thanks again for the quick an comprehensive answer, here are my answers (in reverse order):
Problem(s) solved for now anyway! |
Beta Was this translation helpful? Give feedback.
-
The issue regarding expired tokens with |
Beta Was this translation helpful? Give feedback.
Hi @arminvburren 👋
So, lot of things are going on here. I'll try to dig things one by one.
The login endpoint
I understand that you're trying to open Fief's login page in another window with some JS code to avoid to lose data user may have input in the form. I'm not a big fan of this solution since it breaks a bit the redirection flow.
IMO, I would suggest to revisit this so you store your form data reliably on the user browser. Something like LocalStorage looks like a good candidate: when the user makes change to the form, save it in the local storage. When the user opens the page, you can check if there is data in the LocalStorage and load it into the form. The nice thing with this solu…