CORS on Meteor 2.3

Hi!

I’m using Meteor as a backend and my frontend client is not running on Galaxy.

I’ve been using this setup for a few months without particular issue.
I just had one to fix: CORS. When the client connects to /sockjs/info?cb=, I used to get: “xxx has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.”

A few months back I managed to fix it with adding these lines in the main.ts file:

WebApp.rawConnectHandlers.use((_, res, next) => {
  res.setHeader('Access-Control-Allow-Origin', 'http://localhost:8102');
  res.setHeader('Access-Control-Allow-Origin', 'https://myfrontendserver.com');
  res.setHeader('Access-Control-Allow-Headers', 'Authorization,Content-Type');
  return next();
});

However, it has been failing again for some days (less than a month) but I haven’t been able to clearly identified when. I’m quite sure it’s because of an update (Meteor 2.2?). I’ve just updated to 2.3 and it didn’t solve it. I don’t think I’ve done any change in the code that could have an impact on this.

What bothers me is that locally when I run the server in debug, it never calls this handler. I even added logs and they don’t show up. So basically, it seems that WebApp.rawConnectHandlers.use doesn’t work anymore.

Is anyone aware of changes around this?
Or any different workaround for CORS issues?

Thanks!

Which ddp client do you use?

I use SimpleDDP and I haven’t had issues with CORS, even I haven’t had to configure it when I use that ddp client.

Thanks.

Actually I’m using https://angular-meteor.com/ and I’m not really sure what DDP client is used, to be honest…

I don’t think this is related to Galaxy but if you think so please open a ticket at support@meteor.com

Thank you both for your replies.I think you are right, I was mislead: the CORS errors appeared when the container itself was down.So I was not looking at the right place, issues are not with CORS but with my app that is unstable.

1 Like

Can I suggest that you add your post title with “[Closed]” or something similar? That makes it easier for others.

Thank you!

This sounds stupid, but I really don’t find where to edit the title (or even the first message) :grimacing: