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: headers cannot be set #12

Merged
merged 2 commits into from
Sep 20, 2024
Merged

Conversation

nmsbnmsb1
Copy link
Contributor

Problem: When using options.headers = { ...header }, the headers were not correctly applied to the request.

Solution: I replaced options.headers = { ...header } with options.headers = header. By assigning the headers directly, the issue is resolved, and the HTTP headers are now set correctly.

Copy link

vercel bot commented Sep 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
shadcnui-boilerplate-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 20, 2024 9:56am

Copy link

vercel bot commented Sep 13, 2024

@nmsbnmsb1 is attempting to deploy a commit to the TinsFox Studio Team on Vercel.

A member of the Team first needs to authorize it.

@TinsFox
Copy link
Owner

TinsFox commented Sep 16, 2024

@nmsbnmsb1

Hey, can you explain where exactly it is not set properly?

It would be great if you could provide screenshots.

My test here is normal. This is my test result:

Cursor 2024-09-16 13 51 14 image

@nmsbnmsb1
Copy link
Contributor Author

nmsbnmsb1 commented Sep 17, 2024

My code like this:
const header = new Headers(options.headers);
const token = getToken();
if (token) {
header.append("Token", token);
}
options.headers = header;

I believe this Header instance is used for setting headers, so I used its API to configure them.

When I used the destructuring operator,
options.headers ={ ... header }
I found that I couldn’t add the Token field to the HTTP headers, so I made this modification
options.headers = header

If this wasn’t your intention, please ignore my request.
Thanks : )

@TinsFox
Copy link
Owner

TinsFox commented Sep 18, 2024

Can you try this code snippet?

const token = getToken();
if (token) {
	header.set("Token", token)
}

Maybe you should use set instead of append.

@nmsbnmsb1
Copy link
Contributor Author

Hello. I have tried. Here are the results.

useSet
useSet2

Please verify and test.
Thanks

@TinsFox
Copy link
Owner

TinsFox commented Sep 20, 2024

@nmsbnmsb1 You are right, but I am working on other new features now. I will merge this PR later. Thanks

@TinsFox TinsFox merged commit 16b804e into TinsFox:main Sep 20, 2024
1 of 3 checks passed
@nmsbnmsb1 nmsbnmsb1 deleted the fix_http_header branch September 20, 2024 12:09
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