File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed
Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -94,15 +94,13 @@ app.UseViteStaticFiles();
9494
9595``` c#
9696// With custom authorization:
97- app .UseViteStaticFiles (new ViteStaticFilesOptions
97+ app .UseViteStaticFiles (new ()
9898{
99- OnAuthorizeAsync = async ctx =>
100- {
101- if (ctx .Context .User ? .Identity ? .IsAuthenticated == true ) return true ;
102- // Return false to deny access to specific files.
103- // You can control file names with `manualChunks` in vite.config.ts.
104- return ! ctx .File .Name .Contains (" private" );
105- }
99+ OnAuthorizeAsync = ctx => ctx .Context .Request .Path .StartsWithSegments (" /assets" ) == true
100+ // Vite compiled assets require authentication
101+ ? ValueTask .FromResult (ctx .Context .User .Identity ? .IsAuthenticated == true )
102+ // Anything else (e.g. `arc/public` directory) do not.
103+ : ValueTask .FromResult (true )
106104});
107105```
108106
You can’t perform that action at this time.
0 commit comments