Skip to content

adding development time static files proxying#2207

Merged
Erwinvandervalk merged 10 commits into
mainfrom
ev/bff/static
Sep 15, 2025
Merged

adding development time static files proxying#2207
Erwinvandervalk merged 10 commits into
mainfrom
ev/bff/static

Conversation

@Erwinvandervalk

@Erwinvandervalk Erwinvandervalk commented Sep 10, 2025

Copy link
Copy Markdown
Contributor

What issue does this PR address?
Right now, the BFF allows you to proxy an index html document. This works great in production, but not so great during development.

Suggestion:
Add a proxying method that proxies all static assets, including web sockets. This works great for development. Then provide an easy method for switching.

fixes https://github.com/DuendeSoftware/products-private/issues/2265

Important: Any code or remarks in your Pull Request are under the following terms:

If You provide us with any comments, bug reports, feedback, enhancements, or modifications proposed or suggested by You for the Software, such Feedback is provided on a non-confidential basis (notwithstanding any notice to the contrary You may include in any accompanying communication), and Licensor shall have the right to use such Feedback at its discretion, including, but not limited to the incorporation of such suggested changes into the Software. You hereby grant Licensor a perpetual, irrevocable, transferable, sublicensable, nonexclusive license under all rights necessary to incorporate and use your Feedback for any purpose, including to make and sell any products and services.

(see our license, section 7)

@Erwinvandervalk Erwinvandervalk marked this pull request as ready for review September 11, 2025 09:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds support for static file proxying in development environments while maintaining CDN support for production. The main change introduces a new StaticAssetsUrl property to BffFrontend that allows proxying all static assets (JS, CSS, images) through the BFF server, which is particularly useful for development scenarios with hot-reloading dev servers.

  • Replaces IndexHtmlUrl with CdnIndexHtmlUrl and adds StaticAssetsUrl for full asset proxying
  • Implements mutual exclusion between CDN and proxying modes to prevent configuration conflicts
  • Adds extension methods to dynamically choose between CDN and proxying based on environment

Reviewed Changes

Copilot reviewed 26 out of 27 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
BffFrontend.cs Core model changes adding StaticAssetsUrl and CdnIndexHtmlUrl with mutual exclusion logic
StaticFilesHttpClient.cs New implementation replacing IndexHtmlHttpClient with static asset proxying capabilities
ProxyStaticFilesMiddleware.cs Updated middleware to handle both index HTML and static asset proxying
BffFrontendExtensions.cs New extension methods for configuring static assets with environment-based switching
Test files Updated tests to use new property names and test static asset proxying functionality
Host projects Example configurations showing development vs production usage patterns

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread bff/src/Bff/DynamicFrontends/BffFrontend.cs Outdated
Comment thread bff/src/Bff/DynamicFrontends/BffFrontend.cs
Comment thread bff/src/Bff/DynamicFrontends/BffFrontend.cs Outdated
Comment thread bff/src/Bff/DynamicFrontends/BffFrontend.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 29 out of 30 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread bff/src/Bff/DynamicFrontends/BffFrontend.cs Outdated
Comment thread bff/src/Bff/DynamicFrontends/BffFrontendExtensions.cs Outdated
Comment thread bff/src/Bff/DynamicFrontends/Internal/StaticFilesHttpClient.cs Outdated
Erwinvandervalk and others added 2 commits September 12, 2025 10:31
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Erwinvandervalk Erwinvandervalk force-pushed the ev/bff/static branch 2 times, most recently from 2c8a53d to fd1444a Compare September 15, 2025 05:49
@Erwinvandervalk Erwinvandervalk merged commit 1161d4d into main Sep 15, 2025
14 checks passed
@Erwinvandervalk Erwinvandervalk deleted the ev/bff/static branch September 15, 2025 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants