@squiz/dxp-service-url-lib
v1.66.3
Published
Library for parsing and resolve DXP service URLs.
Downloads
77
Maintainers
Keywords
Readme
@squiz/dxp-service-url-lib
Library for parsing and resolve DXP service URLs.
Supports the following /__dxp URL structures:
- DXPC URLs with tenant and region.
- Matrix URLs with tenant and region (legacy).
- Matrix URLs without tenant and region (will have
/serviceimmediate after/__dxp).
What is this package useful for?
- Parsing the
x-dxp-service-request-urlrequest header and constructing URLs to other paths/services that can be used to route through the same Cloudflare entry point.
Installation
- Ensure you are a member of the Squiz organisation and logged in via the NPM CLI.
- Run:
npm i @squiz/dxp-service-url-lib --save.
Usage
import { DxpServiceUrl } from '@squiz/dxp-service-url-lib';
const url = new DxpServiceUrl('https://dxp.squiz.cloud/__dxp/us/components-render/dx-team-dev-1650/health');
const resolvedUrl = url.resolve({
serviceName: 'page-render', // optional (retains service from initial URL if not provided)
path: '/updated/path', // required
search: '?q=hi' // optional
});
// https://dxp.squiz.cloud/__dxp/us/page-render/dx-team-dev-1650/updated/path?q=hi
console.log(resolvedUrl.toString());