docs-serwist-runtime-caching-routing-reg-exp-route.md
Workbox
RegExpRoute makes it easy to create a Route object with a regular expression.
For same-origin requests the RegExp only needs to match part of the URL. For requests against third-party servers, you must define a RegExp that matches the start of the URL.
regExp — The regular expression to match against URLs.handler — A callback function that returns a Promise resolving to a Response.method — The HTTP method to match the route against. Defaults to GET.sw.ts
import { NetworkFirst, RegExpRoute, Serwist } from "serwist";
const serwist = new Serwist();
serwist.registerRoute(new RegExpRoute(/^\/api\/.*/, new NetworkFirst(), "POST"));
serwist.addEventListeners();
Here is a list of resources you can read to learn more about RegExpRoute: