How to Proxy Requests to Pa11y Webservice Hosted on Heroku

How to Proxy Requests to Pa11y Webservice Hosted on Heroku

Official Pa11y logo
Official Pa11y logo

Pa11y-Dashboard runs of top of Pa11y Webservice (WS).
By default Pa11y WS listens on port 3000 and Pa11y Dashboard listens on port 4000.
Unfortunately Heroku doesn’t allow its users to easily expose multiple ports per application.

To overcome this limitation, I’ve decided to make Pa11y-Dashboard proxy requests to WS via /ws/ endpoint.

After a bit of searching I’ve found a dedicated proxy module for expressjs called express-http-proxy .

Integration is really simple as it’s literally 2 lines of code:

@@ -23,12 +23,28 @@ const hbs = require('express-hbs');
 const http = require('http');
 const pkg = require('./package.json');
+// Initialize proxy module
+const proxy = require('express-http-proxy');
 module.exports = initApp;
        let webserviceUrl = config.webservice;
        if (typeof webserviceUrl === 'object') {
                webserviceUrl = `http://${}:${webserviceUrl.port}/`;
@@ -54,6 +70,13 @@ function initApp(config, callback) {
                extended: true
+       // Proxy requests to WebService
+       // It will use the same basic auth credentials as all other endpoints
+'/ws/', proxy(webserviceUrl));

Once the change is deployed to Heroku you will be able to access Pa11y Webservice via /ws/ endpoint, e.g.:

curl --user a

PS. If you followed my earlier tutorial on adding basic-auth to Pa11y , then you should know that basic-auth will be also added to /ws/ endpoint.