This repository was archived by the owner on Sep 3, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
src/SqlStreamStore.HAL.DevServer Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66 using System . Threading . Tasks ;
77 using KestrelPureOwin ;
88 using Microsoft . AspNetCore . Server . Kestrel . Core ;
9+ using Microsoft . Owin ;
910 using SqlStreamStore . Streams ;
1011 using MidFunc = System . Func <
1112 System . Func <
@@ -57,6 +58,7 @@ await server.Start(new UriBuilder
5758 private static Action < BuildFunc > Configure ( IStreamStore streamStore )
5859 => builder => builder
5960 . Use ( DisplayErrors )
61+ . Use ( AllowAllOrigins )
6062 . Use ( SqlStreamStoreHalMiddleware . UseSqlStreamStoreHal ( streamStore ) ) ;
6163
6264 private static MidFunc DisplayErrors => next => async env =>
@@ -71,6 +73,20 @@ private static Action<BuildFunc> Configure(IStreamStore streamStore)
7173 }
7274 } ;
7375
76+ // don't actually do this in production
77+ private static MidFunc AllowAllOrigins => next => env =>
78+ {
79+ var context = new OwinContext ( env ) ;
80+
81+ context . Response . OnSendingHeaders ( _ =>
82+ {
83+ var response = ( IOwinResponse ) _ ;
84+ response . Headers [ "Access-Control-Allow-Origin" ] = "*" ;
85+ } , context . Response ) ;
86+
87+ return next ( env ) ;
88+ } ;
89+
7490 private static void DisplayMenu ( IStreamStore streamStore )
7591 {
7692 while ( true )
You can’t perform that action at this time.
0 commit comments