🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

cors-tester

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cors-tester

Makes a cors-request by Phantomjs

0.1.1
latest
Source
npm
Version published
Maintainers
1
Created
Source

cors-tester

cors-tester is used for testing CORS-request to a server. Makes a XHR request to a specified endpoint. Whole process takes about 2 seconds.

##Getting started ###Download cors-tester npm install cors-tester

###Using cors-tester

var corsTesterLib = require('cors-tester');
//Full return values, with errors and responses
corsTesterLib.makeCorsRequest('http://localhost:9000', function(returnValue) {
  console.log(returnValue);
});

//OR a very simplified response
corsTesterLib.simpleTest('http://localhost:9000', function(returnValue) {
  console.log(returnValue);
});

//These will make a GET request from Origin: http://localhost:4006 to the specified url
//Which means that the server should return proper Access-Control headers allowing http://localhost:4006 to access

// The first parameter can also be an object with the following variables
var config = {
  port: 4447, //Default=4006
  url: 'http://localhost:9000',
  method: 'POST' //Default="GET"
};
corsTesterLib.simpleTest(config, function(returnValue) {
  console.log(returnValue);
});

##How it works

  • Setups a node.js http-server that serves a single html file
  • The file is opened by Phantom.js browser with url-parameters
  • The html contains a script that makes a XHR-request to an url specified in the url-parameters
  • The application catches XHR-requests and responses and delivers them to the user

##Testing npm test

FAQs

Package last updated on 27 Feb 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts