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

Cors headers dropped in miniflare@v2 #73

Closed
maraisr opened this issue Oct 29, 2021 · 3 comments
Closed

Cors headers dropped in miniflare@v2 #73

maraisr opened this issue Oct 29, 2021 · 3 comments
Labels
bug Something isn't working fixed-in-next Fixed in next release

Comments

@maraisr
Copy link

maraisr commented Oct 29, 2021

With a worktop project, cors headers seem to be dropped in miniflare v2 as opposed to v1.

import { Router } from "worktop";
import { preflight } from "worktop/cors";
import * as Module from "worktop/module";
import { send } from "worktop/response";

const API = new Router();

API.prepare = preflight({
	methods: ["POST", "GET"],
	origin: false,
});

API.add("POST", "/test", async () => {
    return send(200);
});

export default Module.reply(API.run);

curl -v -X OPTIONS localhost:8787/test

Notice no;

< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: POST,GET

Despite miniflare v1 has these.

@mrbbot
Copy link
Contributor

mrbbot commented Oct 29, 2021

Hey! 👋 Which version of worktop are you using? I can't seem to import send from worktop/response?

I've tried the example here (https://github.com/lukeed/worktop/tree/master/examples/workers/cors) and it appears to be working in Miniflare 2. 😕

There's a chance this will be fixed by an issue with enumerable properties on Responses I've just fixed though. I'm hoping to get another pre-release you could try out soon. 👍

@maraisr
Copy link
Author

maraisr commented Oct 29, 2021

ah! 🤪😅 silly me should have told you which versions 😔

worktop@next ☝🏻

@mrbbot mrbbot added bug Something isn't working fixed-in-next Fixed in next release labels Oct 30, 2021
@mrbbot
Copy link
Contributor

mrbbot commented Oct 30, 2021

Hey! 👋 miniflare@2.0.0-next.2 has just been released, including a fix for this. You can find the changelog here. Please let me know if you have any other issues, and feel free to ask questions in the #miniflare channel of the Cloudflare Workers Discord server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed-in-next Fixed in next release
Projects
None yet
Development

No branches or pull requests

2 participants