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

Throw unexpected error #249

Open
wqcstrong opened this issue May 31, 2024 · 0 comments
Open

Throw unexpected error #249

wqcstrong opened this issue May 31, 2024 · 0 comments

Comments

@wqcstrong
Copy link

I've been using the Router from itty-router in a Cloudflare Worker, and I've encountered some unexpected behavior during its usage. The simplified logic of the code is to return the content of https://example.com upon receiving a user request.

// Without using itty-router
export default {
  async fetch(request) {
    return await fetch('https://example.com');
  }
}

When testing in the local development environment using curl, I received the normal HTML content from example.com:

curl http://localhost:8787/

After introducing itty-router:

import { Router, cors, error, json, text, withParams } from 'itty-router';

const { preflight, corsify } = cors({
	origin: /.*/,
	credentials: true,
});

const router = Router({
	before: [preflight, withParams],
	catch: error,
	finally: [corsify, json],
});

router.all('/test', () => {
  return await fetch('https://example.com');
})

export default {
  ...router
}

Continuing the test with curl http://localhost:8787/test, I received the following response:

{"status":500,"error":"Can't modify immutable headers."}%

Could someone please explain what might be causing this issue?

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