Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix captcha cache control bug #2326

Merged
merged 1 commit into from
Jan 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/shared/components/home/signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,13 @@ export class Signup extends Component<any, State> {

async fetchCaptcha() {
this.setState({ captchaRes: LOADING_REQUEST });
HttpService.client.setHeaders({
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be helpful to add functionality to the JS client to set headers for individual requests. This time it doesn't matter too much: the signup page should only be visible to unauthenticated users, so we don't have to worry about overwriting the authentication header. However, I can see this making things needlessly difficult down the line.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If its just a few times too, it might be useful to just create either a separate client without headers on demand, or in HTTPService. Adding optional function params to every lemmy-js-client call might be overkill.

"Cache-Control": "private, no-cache",
});
this.setState({
captchaRes: await HttpService.client.getCaptcha(),
});
HttpService.client.setHeaders({});

this.setState(s => {
if (s.captchaRes.state === "success") {
Expand Down