{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["img"]},"type":"markdown"},"seo":{"title":"Setting up a Reverse Proxy using Vercel","description":"Integrate and automate your content creation process with Foleon's powerful API.","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"setting-up-a-reverse-proxy-using-vercel","__idx":0},"children":["Setting up a Reverse Proxy using Vercel"]},{"$$mdtype":"Tag","name":"div","attributes":{"style":{"padding":"1em","backgroundColor":"#fff3cd","borderLeft":"5px solid #ffeeba","margin":"1em 0"}},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["⚠️ Warning:"]}," This guide provides a general overview of the configuration process. Technical requirements vary by environment; always consult your internal IT or security teams before applying these settings. If you would like to complete this setup with a Foleon technical expert, please contact ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Foleon Support"]}," or your ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Customer Success Manager."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"1-adding-your-domain-into-foleon","__idx":1},"children":["1. Adding your domain into Foleon"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["login to Foleon"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["go to \"Domains\" in the Admin Console (or your workspace)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Use HTTPS protocol to ensure End to End encryption"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Click \"Create new Domain\""]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Fill in the domain"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Click the checkbox for reverse proxy"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["(optional) enter your certificate details"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Click \"save\""]}]},{"$$mdtype":"Tag","name":"Image","attributes":{"src":"/assets/domains.3b86bffae10ff009a14daf55021f0e6bac24bc78dff6fe695f1202d24a89f377.9c1bb791.gif","alt":"domains.gif","withLightbox":true,"width":"","height":""},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"2-configure-the-reverse-proxy-using-nextjs","__idx":2},"children":["2. Configure the Reverse Proxy using Next.js"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Use the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["rewrites"]}," function in your configuration file:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"module.exports = {\n  async rewrites() {\n    return [\n      {\n        source: '/:path*',\n        destination: 'https://s1.foleon.com/en/guides/:path*',\n      },\n    ]\n  },\n}\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"div","attributes":{"style":{"padding":"1em","backgroundColor":"#e7f5ff","borderLeft":"5px solid #339af0","margin":"1em 0"}},"children":["\n  Change ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/en/guides/"]}," to your preferred base path.\n"]},{"$$mdtype":"Tag","name":"div","attributes":{"style":{"padding":"1em","backgroundColor":"#e7f5ff","borderLeft":"5px solid #339af0","margin":"1em 0"}},"children":["\n  Change the destination to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://s1.us.foleon.com/en/guides/:path*"]}," if your content is hosted in the US.\n"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"3-add-middleware-to-set-the-x-forwarded-host","__idx":3},"children":["3. Add middleware to set the X-Forwarded-Host"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Vercel rewrites alone are not sufficient for Foleon. You must forward the original host using middleware. Create a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["middleware.ts"]}," script in your root folder (same level as ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["package.json"]},") and add the following:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"import { NextResponse } from 'next/server'\nimport type { NextRequest } from 'next/server'\n\nexport function middleware(request: NextRequest) {\n  const { pathname, search } = request.nextUrl\n\n  if (!pathname.startsWith('/en/guides')) {\n    return NextResponse.next()\n  }\n\n  const hostname = request.headers.get('host')\n  const destination = `https://s1.foleon.com${pathname}${search}`\n\n  const requestHeaders = new Headers(request.headers)\n  if (hostname) {\n    requestHeaders.set('x-forwarded-host', hostname)\n  }\n\n  return NextResponse.rewrite(new URL(destination), {\n    request: {\n      headers: requestHeaders,\n    },\n  })\n}\n\nexport const config = {\n  matcher: ['/en/guides/:path*'],\n}\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"div","attributes":{"style":{"padding":"1em","backgroundColor":"#e7f5ff","borderLeft":"5px solid #339af0","margin":"1em 0"}},"children":["\n  Change ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/en/guides/"]}," to your preferred base path.\n"]},{"$$mdtype":"Tag","name":"div","attributes":{"style":{"padding":"1em","backgroundColor":"#e7f5ff","borderLeft":"5px solid #339af0","margin":"1em 0"}},"children":["\n  Change the destination to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://s1.us.foleon.com/en/guides/:path*"]}," if your content is hosted in the US.\n"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"3-deploy-and-test","__idx":4},"children":["3. Deploy and Test"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Deploy:"]}," Push your changes to your repository or run ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["vercel --prod"]},"."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Verify:"]}," Navigate to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://yourcompany.com/en/guides/"]},". You should see a Foleon ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["404"]}," page. This confirms Vercel is successfully communicating with Foleon’s servers."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Success:"]}," Once you complete Step 4, your content should load seamlessly."]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"4-apply-a-domain-to-a-project","__idx":5},"children":["4. Apply a domain to a project"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Login to foleon."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Go to project settings."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Select the newly created domain."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Setup the basepath / subfolder you want to use to publish your documents on."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Make sure to publish a document in this project."]}]},{"$$mdtype":"Tag","name":"div","attributes":{"style":{"padding":"1em","backgroundColor":"#e7f5ff","borderLeft":"5px solid #339af0","margin":"1em 0"}},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["TIP:"]}," You can setup multiple projects with the same basepath e.g. ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/en/guide/finance/"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/en/guide/legal/"]}]}]},"headings":[{"value":"Setting up a Reverse Proxy using Vercel","id":"setting-up-a-reverse-proxy-using-vercel","depth":1},{"value":"1. Adding your domain into Foleon","id":"1-adding-your-domain-into-foleon","depth":2},{"value":"2. Configure the Reverse Proxy using Next.js","id":"2-configure-the-reverse-proxy-using-nextjs","depth":2},{"value":"3. Add middleware to set the X-Forwarded-Host","id":"3-add-middleware-to-set-the-x-forwarded-host","depth":2},{"value":"3. Deploy and Test","id":"3-deploy-and-test","depth":2},{"value":"4. Apply a domain to a project","id":"4-apply-a-domain-to-a-project","depth":2}],"frontmatter":{"seo":{"title":"Setting up a Reverse Proxy using Vercel"}},"lastModified":"2026-03-31T15:29:30.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/guides/reverse_proxy/vercel","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}