You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/bff/fundamentals/multi-frontend/index.mdx
+46-1Lines changed: 46 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -155,14 +155,59 @@ var frontend = new BffFrontend(BffFrontendName.Parse("frontend1"))
155
155
156
156
See the topic on [Token Management](/bff/fundamentals/tokens.md) for more information about the various token management options.
157
157
158
-
## Index HTML Proxying
158
+
## Handling SPA static assets
159
+
160
+
The BFF can be configured to handle the static file assets that are typically used when developing SPA based apps.
161
+
162
+
### Proxying the Index.HTML only
159
163
160
164
When deploying a multi-frontend BFF, it makes most sense to have the frontend's configured with an `index.html` file that is retrieved from a Content Delivery Network (CDN).
161
165
166
+
This can be done in various ways. For example, if you use Vite, you can publish static assets with a 'base' configured. This will make sure that any static asset,
167
+
(such as images, scripts, etc) are retrieved directly from the CDN. This gives the best performance.
Whenyoudothis, theBFFautomaticallywiresupacatch-allroutethatservesthe `index.html` for that specific frontend.
168
175
See [Serve the index page from the BFF host](/bff/architecture/ui-hosting.md#serve-the-index-page-from-the-bff-host) for more information.
176
+
177
+
### Proxying all static assets
178
+
179
+
When developing a SPA based application, it's very common to use a development webserver such as Vite. While vite can publish static assets with a 'base',
180
+
this doesn't work well during development.
181
+
182
+
The best development experience can be achieved by configuring the BFF to proxy all static assets from the development server:
183
+
184
+
185
+
```csharp
186
+
var frontend = new BffFrontend(BffFrontendName.Parse("frontend1"))
187
+
.WithProxiedStaticAssets(newUri("https://localhost:3000")); // https://localhost:3000 would be the URL of your development web server.
188
+
```
189
+
190
+
While this can also be done in production, it will proxy all static assets through the BFF. This will increase the bandwidth consumed by the BFF
191
+
and reduce the overall performance of your application.
192
+
193
+
194
+
### Proxying assets based on environment
195
+
196
+
If you're using a local development server during development, but a CDN in production, you can also configure this as follows:
197
+
198
+
```csharp
199
+
200
+
// In this example, the environment name from the application builder is used to determine
0 commit comments