bigskysoftware / bigskysoftware/htmx

HX-Redirect does not work in chrome

Open
#2,359 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
49.4k
Forks
1.7k
Avg merge
3d 22h
Merged PRs (30d)
30

Description

I have a login.html for the user. If he/she pass the authorization the browser should lead he/she to the home page(home.html). If the username or password is wrong, an hint is sent from the server to the browser and shown on login.html page.

everything looks normal when login failed. But if the authorization sucess, the browser can not be redirect to /home. it's still at /login(from the backend we can see '/dologin' returns sucessfully and '/home' is not executed).

After tried many times, I found it can be corrected by 2 method:
1. clear brwoser cache before connecting.
2. Press F12 to open chrome debug window before click "login" button. (I don't understand why it works! But it does work!!!)
But I can't ask all of the users to do it. It's ugly.

Anybody had the same issue?

In my project, I use htmx.min.js(version 1.9.10) in the frontend and freepascal in the back end. windows 11, chrome 122.0.6261.70. My code like this:

login.css:
```
.wrapper .showErrorInfo {
position: absolute;
color: var(--text-light-clr);
z-index: -1;
padding: 400px 20px 60px 80px;
opacity: 0;
animation: showWrongLoginMsg 3s linear alternate-reverse;
}
@keyframes showWrongLoginMsg {
form {
opacity: 0;
}
to {
opacity: 1;
}
}
```

login.html
```



Login





UserName




Password


Login






```

MyRouters.pas
```
procedure TRouteDoLogin.DoRequest(ASender: TObject; ARoute: TBrookURLRoute;
ARequest: TBrookHTTPRequest; AResponse: TBrookHTTPResponse);
var
uname,pwd,cid:string;
begin
uname:=ARequest.Fields.Get('username');
pwd:=ARequest.Fields.Get('password');
if wwwDM.LoginUser(uname,pwd,cid) then begin
AResponse.SetCookie('cid', cid);
AResponse.Headers.Add('HX-Redirect','/home');
AResponse.Send('login ok','text/html; charset=utf-8', 200);
end else begin
AResponse.Send(
'Wrong user name or password',
'text/html; charset=utf-8', 200);
end;
end;
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.