Skip to content

Conversation

AntaresQAQ
Copy link
Contributor

@AntaresQAQ AntaresQAQ commented Jul 8, 2025

How to repro:

Use a non-Chinese IP

code

const query = `
query questionOfToday {
    todayRecord {
        date
        userStatus
        question {
            questionId
            frontendQuestionId: questionFrontendId
            difficulty
            title
            titleCn: translatedTitle
            titleSlug
            paidOnly: isPaidOnly
            freqBar
            isFavor
            acRate
            status
            solutionNum
            hasVideoSolution
            topicTags {
                name
                nameTranslated: translatedName
                id
            }
            extra {
                topCompanyTags {
                    imgUrl
                    slug
                    numSubscribed
                }
            }
        }
        lastSubmission {
            id
        }
    }
}`;

fetch("https://leetcode.cn/graphql/", {
  headers: {
    // accept: "application/json",
    // "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
    "content-type": "application/json",
  },
  body: JSON.stringify({
    query,
    variables: {},
    operationName: "questionOfToday",
  }),
  method: "POST",
})
  .then((resp) => {
    console.log("Response status:", resp.status);
    resp.text().then((text) => {
      console.log(text.slice(0, 300));
    });
  })
  .catch((err) => console.error(err));

Results

Response status: 403
<!DOCTYPE html><html lang="en-US"><head><title>Just a moment...</title><meta http-equiv="Content-Type" content="text/html; char...
image

Expected results

Response status: 200
{"data":{"todayRecord":[{"date":"2025-07-08","userStatus":null,"question":{"questionId":"1851","frontendQu......

How to fix:

Add these HTTP headers:

Accept: application/json
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8

Validate the fix:
image

@changeset-bot
Copy link

changeset-bot bot commented Jul 8, 2025

🦋 Changeset detected

Latest commit: f967d70

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
leetcode-query Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@AntaresQAQ
Copy link
Contributor Author

Hi @JacobLinCool , please help to review! Thank you! ❤️

Copy link
Owner

@JacobLinCool JacobLinCool left a comment

Choose a reason for hiding this comment

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

LGTM. Just want to know that is accept-language necessary?

And, please run pnpm changeset and commit the changeset to make the CI release work.

@AntaresQAQ
Copy link
Contributor Author

LGTM. Just want to know that is accept-language necessary?

And, please run pnpm changeset and commit the changeset to make the CI release work.

Thanks @JacobLinCool , I'm sure that both of them are necessary.
image
image

@AntaresQAQ AntaresQAQ requested a review from JacobLinCool July 10, 2025 00:21
@JacobLinCool JacobLinCool merged commit 1bf288b into JacobLinCool:main Jul 10, 2025
2 checks passed
@github-actions github-actions bot mentioned this pull request Jul 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants