Wir verwenden derzeit die Steam-API für ein Ember-Projekt, haben aber festgestellt, dass die API keine Cross-Origin-Anfragen erlaubt. Als Ergebnis haben wir einen Server basierend auf der Dokumentation here erstellt.Feeding Informationen von einem JS-Server in einen anderen mit Ember
Während wir einen Server erstellt haben, die erfolgreich in der Lage, die API aufrufen und nutzen Sie die Informationen, die wir angefordert haben wir festgestellt, dass der Server auf Port läuft: 4000, und wir müssen es in den Hafen verbinden: 4200.
Gibt es eine Möglichkeit für uns, die Informationen von diesem Server auf den Glutserver zu übertragen? Jede Hilfe würde sehr geschätzt werden.
Unten ist der Code, den wir für den Server verwendet:
var express = require('express');
var app = express();
app.get('/', function(httpRequest, httpResponse) {
httpResponse.send('Hello, World!');
});
app.get('/hello-frank', function(httpRequest, httpResponse) {
httpResponse.send('Hello, Frank.');
});
app.post('/hello-frank', function(httpRequest, httpResponse) {
httpResponse.send("No, Frank. You're not allowed to post.");
});
app.get('/hello/:name', function(httpRequest, httpResponse) {
var name = httpRequest.params.name;
httpResponse.send('Hello, ' + name + '!');
});
var request = require('request');
var url = 'http://api.steampowered.com/ISteamUserStats/GetSchemaForGame/' +
'v2/?key=YOURSTEAMAPIKEYHERE&appid=8930';
request.get(url, function(error, steamHttpResponse, steamHttpBody) {
// Print to console to prove we downloaded the achievements.
console.log(steamHttpBody);
});
app.get('/steam/civ5achievements', function(httpRequest, httpResponse) {
// Calculate the Steam API URL we want to use
var url = 'http://api.steampowered.com/ISteamUserStats/GetSchemaForGame/' +
'v2/?key=YOURSTEAMAPIKEYHERE&appid=8930';
request.get(url, function(error, steamHttpResponse, steamHttpBody) {
// Once we get the body of the steamHttpResponse, send it to our client
// as our own httpResponse
httpResponse.setHeader('Content-Type', 'application/json');
httpResponse.send(steamHttpBody);
});
});
app.get('/steam/game/:appid/achievements', function(httpRequest, httpResponse) {
// Calculate the Steam API URL we want to use
var url = 'http://api.steampowered.com/ISteamUserStats/GetSchemaForGame/' +
'v2/?key=YOURSTEAMAPIKEYHERE&appid=' +
httpRequest.params.appid;
request.get(url, function(error, steamHttpResponse, steamHttpBody) {
httpResponse.setHeader('Content-Type', 'application/json');
httpResponse.send(steamHttpBody);
});
});
app.use('/', express.static('public'));
var bodyParser = require('body-parser');
app.use(bodyParser.text());
app.post('/frank-blog', function(httpRequest, httpResponse) {
console.log(httpRequest.body);
httpResponse.status(200).send('Posted today:\n\n' + httpRequest.body);
var port = 4000;
var server = app.listen(port);
console.log('Listening on port ' + port);