1. Examples
  2. Custom Base Path

Custom Base Path

Remove or rewrite URL paths when forwarding requests to your backend.

Deploy to Zuplo
Deploy to Zuplo

Prerequisite: You need a Zuplo account to run this example. Sign up for free

This examples shows how to store base path and backend server configuration in the servers object of the OpenAPI and then use a policy to dynamically remove the base path and set the forwarded property of the URL in order to send the request to the correct backend server.

Use this example locally

To develop with this example locally, you can create a new Zuplo project using our CLI

Terminalbash
npx create-zuplo-api@latest my-api --example oas-base-path

Then, in the project directory run the following commands:

Terminalbash
npm install
npm run dev

Example OpenAPI Configuration

Adding the custom extension x-base-path to the servers object allows us to match the base path to the correct server url.

JSONjson
  "servers": [
    {
      "url": "https://echo.zuplo.io",
      "x-base-path": "/my-base-1"
    }
  ],

Import the OpenAPI files

Zuplo allows importing the OpenAPI JSON files into a module so their configuration can be read.

TypeScriptts
import { servers as servers1 } from "../config/routes1.oas.json";
import { servers as servers2 } from "../config/routes2.oas.json";

const servers = [...servers1, ...servers2];

A point of caution here. Zuplo's build will import anything that is referenced. So if you import the entire OpenAPI file (i.e. import routes from "../config/routes.oas.json"), the entire contents will be in your build and could impact your Gateway's performance if you have a particularly large file.

This is why, in the above example, only the { servers } portion of the file is imported.

Quick Links

View on GitHubDocumentation

Run Locally

Clone and run this example:

npx create-zuplo-api --example oas-base-path

On This Page

Related Examples

Explore more examples in this category

Idempotency Keys

Programmability

Prevent duplicate API requests and ensure safe retries for payments and critical operations.

View Example

Custom Rate Limiting

Programmability

Customize the error response users see when they hit your API rate limits.

View Example

Custom Modules

Programmability

Use npm packages and third-party libraries in your Zuplo handlers and policies.

View Example

Dynamic Rate Limits

Programmability

Set different rate limits based on user subscription tier or API key metadata.

View Example
Check all of our Examples

Scale your APIs with
confidence.

Start for free or book a demo with our team.
Book a demoStart for Free
SOC 2 TYPE 2High Performer Spring 2025Momentum Leader Spring 2025Best Estimated ROI Spring 2025Easiest To Use Spring 2025Fastest Implementation Spring 2025

Get Updates From Zuplo

Zuplo logo
© 2026 zuplo. All rights reserved.
Products & Features
API ManagementAI GatewayMCP ServersMCP GatewayDeveloper PortalRate LimitingOpenAPI NativeGitOpsProgrammableAPI Key ManagementMulti-cloudAPI GovernanceMonetizationSelf-Serve DevX
Developers
DocumentationBlogLearning CenterCommunityChangelogIntegrations
Product
PricingSupportSign InCustomer Stories
Company
About UsMedia KitCareersStatusTrust & Compliance
Privacy PolicySecurity PoliciesTerms of ServiceTrust & Compliance
Docs
Pricing
Sign Up
Login
ContactBook a demoFAQ
Zuplo logo
DocsPricingSign Up
Login