Embed apidog in subdirectory

Hello,

We’re trying to embed ApiDog into a subdirectory of our own domain and toggled “Use subdirectory” with reverse proxy, however the internal urls in apidog are not being rewritten into the url of the domain that we entered and its still using the same apidog url, what could be the problem here?

For detailed information, please check here: Custom domain - Apidog Docs

If you can provide your nginx configuration, it will be very helpful

Hi Alan,

Thank you for the reply, we assumed it would be a rewrite on apidogs end since if it is not, how would our reverse proxy know what url to call when a user is already on the documentation page and eg clicks a link in the sidebar. I assume ApiDog then has to do a call to our subdomain again with the specific page

Also we’re using YARP if that helps but have not configured anything yet since we’re unsure how (because of the above)

Alan Im a collegue of gkrz

To give an extra (visual) example.

This is our Discount API docs, but the internal link is List all discounts for products - LogicTrade API. See the screenshot as well.

Shouldn’t this be https://[our custom domain]/docs/api-3489546?

Because when those links will not be pointed towards our reverse proxy, its impossible to rewrite right?


Gerjan Thank you for the detailed bug report. Our engineering team has confirmed that this is a bug. They are actively working on a fix and expect to resolve it within this week, potentially as early as tomorrow.

Thank you Karan!

Gerjan The engineer has identified the issue in your documentation. The problem stems from using an iframe to embed the page on your website instead of implementing the correct proxy settings. To resolve this, you need to utilize Nginx to proxy the entire path. For detailed information on configuring your own reverse proxy server, please refer to our documentation at Custom domain - Apidog Docs

Karan Are there also examples for YARP somewhere?

gkrz We are not currently familiar with YARP. The configurations provided is generated using AI based on the official documentation. However, please note that these configurations will require manual testing and verification.

using Yarp.ReverseProxy.Configuration;

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        // ... other services

        services.AddReverseProxy()
            .LoadFromMemory(new[]
            {
                new RouteConfig
                {
                    RouteId = "apidog-proxy",
                    Match = new RouteMatch
                    {
                        Path = "/"
                    },
                    ClusterId = "apidog-cluster"
                },
            },
            new[]
            {
                new ClusterConfig
                {
                    ClusterId = "apidog-cluster",
                    Destinations = new Dictionary<string, DestinationConfig>
                    {
                        { "apidog", new DestinationConfig { Address = $"http://{{projectId}}.apidog.io" } }
                    }
                }
            });
    }

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        // ... other middleware

        app.UseRouting();

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapReverseProxy(proxyPipeline =>
            {
                proxyPipeline.Use(async (context, next) =>
                {
                    // Set custom headers
                    context.ProxyRequest.Headers.Add("X-Apidog-Project-ID", "{projectId}");
                    context.ProxyRequest.Headers.Host = "docs.example.com";

                    await next();
                });
            });
        });
    }
}