Skip to content

Latest commit

 

History

History
34 lines (26 loc) · 834 Bytes

parameterised-mount.md

File metadata and controls

34 lines (26 loc) · 834 Bytes

Mounting on a parameterised URL

You might want to mount your CASA application on a parameterised URL, for example /app/:someId.

For instance, this could be useful if you want to tweak the journey in some way based on this parameter.

import express from "express";
import { configure } from "@dwp/govuk-casa";

// Prep the CASA app
const { mount } = configure({
  session: {
    secret: "secret",
  },
});

// Mount on a parent app
const app = express();
app.use(
  "/app/",
  mount(express(), {
    // All calls to `/app/123`, `/app/something`, etc will now be served by the CASA app
    route: "/:someId",
  }),
);

app.listen();

Note that in your templates, the following variables will apply:

  • casa.mountUrl = /app/abcdef/ (where abcdef is the dynamic parameter)
  • casa.staticMountUrl = /app/