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

Custom headers are missing in local env #30

Closed
subhendukundu opened this issue May 19, 2021 · 1 comment
Closed

Custom headers are missing in local env #30

subhendukundu opened this issue May 19, 2021 · 1 comment

Comments

@subhendukundu
Copy link

const res = await fetch(url, {
    method: "POST",
    headers: new Headers({ "Content-Type": "application/json", token }),
    credentials: "same-origin",
    body: JSON.stringify(data),
});

I am expecting the token in our API like so

async handler({ request }) {
        if (request.method !== "POST") {
            throw new BadRequestError("Method not supported!");
        }
        const { price, metadata = {} } = await request.json();
        const token = request.headers.get("token");
        console.log(token); // undefined here only in local -----------

But it works when deployed.
Any idea why?

@subhendukundu
Copy link
Author

My bad. I was looking at the wrong console. Sorry!

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

No branches or pull requests

1 participant