Advertisement
Guest User

Untitled

a guest
Jul 8th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. var request = require('request'),
  2. username = "asd asd",
  3. password = "asdasd",
  4. url = "https://" + username + ":" + password + "@tmgdemo3.telemagic.no:8894/rest/agent";
  5.  
  6. var express = require('express');
  7. var app = express();
  8.  
  9. app.use(function (req, res, next) {
  10. res.setHeader('Access-Control-Allow-Origin', '*');
  11. res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
  12. // Request headers you wish to allow
  13. res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
  14. // Set to true if you need the website to include cookies in the requests sent
  15. // to the API (e.g. in case you use sessions)
  16. res.setHeader('Access-Control-Allow-Credentials', true);
  17. // Pass to next layer of middleware
  18. next();
  19. });
  20.  
  21. app.get('/agents', function (req, res) {
  22. var result = request.get({
  23. url : url
  24. },
  25. function (error, response, body) {
  26. res.send(body);
  27. });
  28. });
  29.  
  30. app.listen(3000, function () {
  31. console.log('Telemagic Proxy Server: paris.slaattene.com:3000');
  32. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement