Preview Redirects To Login When Session Is Lost #10745

Open
opened 2025-11-02 09:17:12 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @kdumontnu on GitHub (Apr 28, 2023).

Description

The preview frame appears to redirect to the login page if a user loses their session before hitting preview on a page.

To recreate:

  • Sign-in and navigate to a private page with a text box (eg. PR)
  • Delete cookies
  • Press "Preview"

Gitea Version

try.gitea

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

Preview_bug

Git Version

No response

Operating System

No response

How are you running Gitea?

try.gitea

Database

None

Originally created by @kdumontnu on GitHub (Apr 28, 2023). ### Description The preview frame appears to redirect to the login page if a user loses their session before hitting preview on a page. To recreate: - Sign-in and navigate to a private page with a text box (eg. PR) - Delete cookies - Press "Preview" ### Gitea Version try.gitea ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Screenshots ![Preview_bug](https://user-images.githubusercontent.com/12700993/235256865-9c5c2679-5143-4ecf-a86b-1abb7bd2bd7a.gif) ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? try.gitea ### Database None
GiteaMirror added the type/bug label 2025-11-02 09:17:12 -06:00
Author
Owner

@silverwind commented on GitHub (Apr 28, 2023):

Should not redirect in this case, but display an error box related to the outcome of the HTTP request.

@silverwind commented on GitHub (Apr 28, 2023): Should not redirect in this case, but display an error box related to the outcome of the HTTP request.
Author
Owner

@wxiaoguang commented on GitHub (Apr 29, 2023):

It's not a redirect, it just embedded the responded "login" page content into the preview panel.

That's a longstanding problem, not only here, the AJAX requests which fill the responded HTML into current page all have such problem.

And even worse, in this case, the "submit" action will lose the content.

@wxiaoguang commented on GitHub (Apr 29, 2023): It's not a redirect, it just embedded the responded "login" page content into the preview panel. That's a longstanding problem, not only here, the AJAX requests which fill the responded HTML into current page all have such problem. And even worse, in this case, the "submit" action will lose the content.
Author
Owner

@silverwind commented on GitHub (Apr 29, 2023):

Should just stop issueing a redirect and send a 401 error instead when a fetch/xhr request is detected via presence of HTTP origin header.

@silverwind commented on GitHub (Apr 29, 2023): Should just stop issueing a redirect and send a 401 error instead when a fetch/xhr request is detected via presence of HTTP `origin` header.
Author
Owner

@silverwind commented on GitHub (Apr 30, 2023):

Another option would be to error on redirect in the JS. I think this is only possible via fetch API:

https://developer.mozilla.org/en-US/docs/Web/API/fetch#redirect

@silverwind commented on GitHub (Apr 30, 2023): Another option would be to error on redirect in the JS. I think this is only possible via fetch API: https://developer.mozilla.org/en-US/docs/Web/API/fetch#redirect
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#10745