Restivus external api not accessible from another pc

#1

When running the external api in local host it works fine, But trying with another host on my network I’m not gettting anything. Give a solution.

var Api = new Restivus({
useDefaultAuth: false,
prettyJson: true,
enableCors: true,
defaultHeaders: {
‘Access-Control-Allow-Origin’: ‘’,
‘Access-Control-Allow-Headers’: ‘Origin, X-Requested-With, Content-Type, Accept, Z-Key, x-user-id,x-auth-token’,
‘Access-Control-Allow-Methods’: ‘GET, POST, PUT, DELETE, OPTIONS’,
‘Content-Type’: ‘application/json’
},
defaultOptionsEndpoint: function() {
this.response.writeHead(201, {
‘Access-Control-Allow-Origin’: '
’,
‘Access-Control-Allow-Headers’: ‘Origin, X-Requested-With, Content-Type, Accept, Z-Key’,
‘Content-Type’: ‘application/json’,
‘Access-Control-Allow-Methods’: ‘GET, POST, PUT, DELETE, OPTIONS’,
});
}
});

Api.addRoute(‘articles/’, {authRequired: false}, {
get: function () {
console.log(‘executed’)
return Meteor.users.find().fetch();
}

my api: http://192.168.1.153:3000/api/articles
I just hit the api in my crome browser. Any help would be appreciated

#2

Can you access a regular webpage from another PC? Would be good to isolate the issue to Restivus

1 Like
#3

yes, I can. Even in my pc when i hit this api i can see the data from meteor.users collection. But when I try with another pc it not giving any resposes

#4

I’m not certain, but it might be worth looking into CORS

It’s possible that you need to enable access from other domains.

1 Like
#5

Yeah…just testing it

#6

Thank you it was my firewall blcoking it.

#7

Glad you got it sorted