Express Loadmill
Users of Loadmill can use this express middleware for:
- Quick and easy domain verification.
- Enabling CORS strictly from loadmill.com in order to perform crowdsourced load tests.
Installation
Using npm:
npm install express-loadmill --save
Using yarn:
yarn add express-loadmill
Usage
Use loadmill middleware before everything else (that should be exposed to testing):
var app = require('express')();
var Loadmill = require('express-loadmill');
app.use(Loadmill({verifyToken: process.env.LOADMILL_VERIFY_TOKEN}));
The above code enables both CORS and domain verification. You may optionally disable CORS by setting the enableCors
option to false, e.g.
app.use(Loadmill({enableCors: false, verifyToken: process.env.LOADMILL_VERIFY_TOKEN}));
Note however that you will not be able to perform high-volume load tests with loadmill without enabling CORS.
Domain verification will only be enabled if you supply a verification token, thus the following code will only enable CORS:
app.use(Loadmill());
Cookies
To enable cookies being sent to and from the server (by setting Access-Control-Allow-Credentials
response header),
set the enableCookies
option to true
, e.g.
app.use(Loadmill({enableCookies: true, verifyToken: process.env.LOADMILL_VERIFY_TOKEN}));
Note that you will also need to enable cookies for your test in the Advanced Settings section of your test configuration.
Learn More