Skip to main content

The Core Concept: Rewrites

A rewrite acts as a proxy. When a user visits the source path on your domain, your server fetches the content from the destination URL and serves it to the user. Crucially, the URL in the user’s browser bar does not change.
  • Source: The path on your website that you want to use.
  • Destination: The full URL of your Chatbase help center.
Remember to replace {agentId} with your actual Chatbase Agent ID. You can find this ID in your Chatbase dashboard settings.
Required RoutesFor the help center to function correctly, you must proxy these paths:
  • /help and /help/* - The help center pages
  • /__cb/* - Static assets (JavaScript, CSS, images)
  • /api/chat/{agentId}/* - Chat API endpoints for features like lead submission
Replace {agentId} with your actual Agent ID in all rules.

Implementation Examples

Choose the tab below that corresponds to your website’s framework or hosting platform.
For projects using the Next.js framework, you can configure rewrites in your next.config.js file. This is the recommended method for Next.js applications.
  1. Open or create the next.config.js file at the root of your project.
  2. Add the rewrites function to the configuration object.
// next.config.js

/** @type {import('next').NextConfig} */
const nextConfig = {
  async rewrites() {
    return [
      {
        source: "/help",
        destination: "https://chatbase.co/{agentId}/help",
      },
      // This rule is needed to correctly proxy sub-pages of your help center.
      {
        source: "/help/:path*",
        destination: "https://chatbase.co/{agentId}/help/:path*",
      },
      // Proxy static assets (JavaScript, CSS, images)
      {
        source: "/__cb/:path*",
        destination: "https://chatbase.co/__cb/:path*",
      },
      // Proxy chat API endpoints for your agent
      {
        source: "/api/chat/{agentId}/:path*",
        destination: "https://chatbase.co/api/chat/{agentId}/:path*",
      },
    ];
  },
};

module.exports = nextConfig;
After adding this configuration, restart your Next.js development server to apply the changes.
SitemapsYour proxied help center content will not be automatically included in your primary domain’s sitemap. You may need to add these URLs manually if SEO for your help content is a priority.