Multiple App Support

If you use two different apps on the same node runtime, you can create two instances and use them on two routes:

"use strict";

const express = require('express');
const perimeterx = require('perimeterx-node-express');

const server = express();

/* the px-module and parser need to be initialized before any route usage */
const pxConfig1 = {
    pxAppId: 'PX_APP_ID_1',
    cookieSecretKey: 'PX_COOKIE_ENCRYPTION_KEY',
    authToken: 'PX_TOKEN_1'
const middlewareApp1 =;
const app1Router = express.Router();
app1Router.get('/hello', (req, res) => {
    res.send('Hello from App1');
server.use('/app1', app1Router);

const pxConfig2 = {
    pxAppId: 'PX_APP_ID_2',
    cookieSecretKey: 'PX_COOKIE_ENCRYPTION_KEY',
    authToken: 'PX_TOKEN_2'
const middlewareApp2 =;
const app2Router = express.Router();
app2Router.get('/app2', (req, res) => {
    res.send('Hello from App2');
server.use('/app2', app1Router);

server.listen(8081, () => {
    console.log('server started');

Did this page help you?