Skip to content

Instantly share code, notes, and snippets.

@mtharrison
Last active October 22, 2015 16:32
Show Gist options
  • Save mtharrison/65ba1e7f6856df2ba8fa to your computer and use it in GitHub Desktop.
Save mtharrison/65ba1e7f6856df2ba8fa to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script>
var request = new XMLHttpRequest();
request.open('GET', 'http://127.0.0.1:4000/cors', true);
request.setRequestHeader('x-custom-header', 'value');
request.onload = function() {
};
request.onerror = function() {
};
request.send();
</script>
</body>
</html>
var Express = require('express');
var Cors = require('cors');
var app = Express();
app.use(Express.static(__dirname));
app.get('/cors', Cors(), function (req, res) {
res.end('cors');
});
app.listen(4000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment