unoplatform / Uno.Wasm.Bootstrap

A simple nuget package to run C# code in a WASM-compatible browser
Other
364 stars 57 forks source link

fix: pass same-origin credentials - fixes #875 #877

Closed mikeirvingweb closed 1 month ago

mikeirvingweb commented 1 month ago

passing {credentials: "same-origin"} into fetch() calls made by Bootstrapper.ts (uno-bootstrap.jsin eventual web publish) means that the Uno Platform Wasm App will work on web hosting where we are behind authentication, requiring access to an authentication cookie (such as Azure Static Web Apps 'Password Protection')

addresses, fixes #875

mikeirvingweb commented 1 month ago

@carldebilly stick an app in Azure Static Web Apps (paid), turn on Password Protection in Configuration.

Load your App URL, enter your password, if your app loads then the fix works.

Previously the app would fail to load.

mikeirvingweb commented 1 month ago

furthermore @carldebilly

to simulate the deployment, without needing the package change live, publish to a folder, then modify uno-bootstrap.js

then publish your app using swa deploy

carldebilly commented 1 month ago

furthermore @carldebilly

to simulate the deployment, without needing the package change live, publish to a folder, then modify uno-bootstrap.js

  • change omit to same-origin in getFetchInit
  • and in fetchFile, change the return statement to return fetch(asset, {credentials: "same-origin"});

then publish your app using swa deploy

My comment was more about the ability to create an automated tests in the project CI to test this instead of having to manually test it.

jeromelaban commented 1 month ago

Thanks for your contribution! This is likely difficult to validate as-is, but we can definitely try when the dev build will be available. At the very least, the tests passed.