Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var request = require('request'),
- username = "asd asd",
- password = "asdasd",
- url = "https://" + username + ":" + password + "@tmgdemo3.telemagic.no:8894/rest/agent";
- var express = require('express');
- var app = express();
- app.use(function (req, res, next) {
- res.setHeader('Access-Control-Allow-Origin', '*');
- res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
- // Request headers you wish to allow
- res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
- // Set to true if you need the website to include cookies in the requests sent
- // to the API (e.g. in case you use sessions)
- res.setHeader('Access-Control-Allow-Credentials', true);
- // Pass to next layer of middleware
- next();
- });
- app.get('/agents', function (req, res) {
- var result = request.get({
- url : url
- },
- function (error, response, body) {
- res.send(body);
- });
- });
- app.listen(3000, function () {
- console.log('Telemagic Proxy Server: paris.slaattene.com:3000');
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement