I am trying to figure out how to authorize my Node-based app to access the Tumblr API. My JS file looks like:
// server.js
var express = require('express');
var app = express();
var tumblr = require('tumblr.js');
var client = new tumblr.Client({
consumer_key: 'xxx',
consumer_secret: 'yyy',
token: 'zzz',
token_secret: 'aaa'
});
app.use(function(req, res) {
// Make the request
client.userInfo(function (err, data) {
console.log(data);
res.send(data);
});
});
var server = app.listen(9002, function() {
console.log('server listening for incoming connections on port %d', server.address().port);
});
On the client side I have:
// main.js
$(document).ready(function() {
$.get('http://localhost:9002', function(data, status) {
console.log(data);
});
});
The problem is that the response the client receives is "XMLHttpRequest cannot load http://localhost:9002/
. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9000
' is therefore not allowed access. (index):1" The server-side console logs a JSON object that looks correct. I'm running this from my local machine on port 9000 if that makes a difference. How do I get this to work?
Thanks.