Meteor and CORS

Hi guys,

I’m facing a problem like this:
I’m using Angular-Meteor-Ionic to create an App.
The server-side could call to remote API to get data (messages actually) and cache, apply filter ,… bla bla bla. I’ve worked.
The server I run it on my local machine, maybe a standalone server in future. However, I think sometime the server could be stop, that why I want to add a feature, run offline: whenever the app detect that server has stopped, it could call API directly get and show message (temporary). I already done this too. However, CORS is a big issue to run the app on production. Right now, I’ve to run corsproxy on my machine to bypass this problem.

Could anyone show me how to call remote API that would pass CORS? I CAN’T touch remote machine.

I read this topic: Set up Angular Constant
And I’m wondering: how can I use angular Constant on my project.
@Urigo: could you help me make clear about this constant???

Thank you all!
MNChau.

The whole point of CORS is that you can’t do this. You either need to make the call from a server, or modify the API to accept cross-origin requests.

Thanks for your reply, @sashko.
How about that post from ionic blog? They said about using angular constant with IONIC. I didn’t know how to set up that (meteor + angular + ionic is like a little tricky and messy to me, still learning and try to figure them out)

The constant thing doesn’t help at all when your server us not running. the article simply talks about how in ionic the API endpoint needs to be called through a different URL depending on if you’re in development or production which wouldn’t be an issue with Meteor.

@sashko,
If I have to call those API from Meteor server, that really wouldn’t be an issue at all. Everything work fine.
The problem is from client call. But, from what I read, maybe I have to change the remote server policy (which I can’t) or I have to accept the fact that data alway come from the server call.
Maybe from a free cors-proxy server, but security must be concerned here.
Thanks anyway, it’s really helpful.
Regards!

1 Like