Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Configurable CDN for Default Pode Static Pages #1522

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

mdaneri
Copy link
Contributor

@mdaneri mdaneri commented Mar 15, 2025

Summary

This pull request introduces a new feature that allows users to configure the CDN source for serving default Pode static pages, such as Swagger UI. This improves reliability and performance by allowing users to choose from multiple CDN providers.

Why This Change?

Currently, Pode defaults to using https://unpkg.com for serving static assets. However, unpkg has proven to be unreliable due to the following reasons:

  • Frequent Downtime: unpkg.com has experienced periods of unavailability, causing failures in serving assets.
  • No Built-in Redundancy: Unlike jsDelivr, unpkg.com lacks automatic fallback mechanisms.
  • Performance Issues: Users have reported inconsistent load times affecting page rendering.
  • Enterprise Restrictions: Some corporate environments block unpkg.com, leading to accessibility issues.

To address these concerns, this change introduces a configurable CDN option, allowing users to select a more stable and performant source.

Feature Details

A new ContentDeliveryNetwork setting is introduced under Web.Static in server.psd1. This setting allows users to specify which CDN should be used for serving default static assets.

Supported CDNs

  • https://cdn.jsdelivr.net/npm (default)
  • https://unpkg.com
  • https://cdnjs.cloudflare.com/ajax/libs (requires URL modifications)

Example Configuration in server.psd1

Users can specify their preferred CDN in their Pode configuration:

@{
    RestFulPort = 8081
    Protocol = 'Http'
    Address = 'localhost'
    Server = @{
        Timeout = 60
        BodySize = 100MB
    }
    Web = @{
        OpenApi = @{
            DefaultDefinitionTag = 'v3.0.3'
        }
        Static = @{
            ContentDeliveryNetwork = 'https://cdn.jsdelivr.net/npm'
        }
    }
}

Implementation Notes

  • The default CDN is https://cdn.jsdelivr.net/npm to provide better reliability.
  • Users can override this setting by specifying a different CDN in their configuration.
  • If the ContentDeliveryNetwork key is missing, Pode will fall back to the default (jsDelivr).
  • The change ensures backward compatibility with existing Pode configurations.

Testing

  • Verified that Pode correctly loads Swagger UI from different CDN sources.
  • Tested fallback behavior when no CDN is specified.
  • Ensured no breaking changes for users who do not set this configuration.

Benefits of This Change

Increased Reliability – Users can avoid any CDN that has downtime by switching to a more stable CDN.
Flexibility – Users can choose the best CDN for their environment, avoiding corporate restrictions.
Seamless Integration – Backward compatible with existing configurations.

Fix: #1523

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unpkg.com Returning Errors for Swagger UI Assets
1 participant