Add CORS headers
This commit is contained in:
parent
b2eea0abb9
commit
f909fce1b7
2 changed files with 6 additions and 0 deletions
|
@ -24,4 +24,7 @@
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="CopyToPlugins" AfterTargets="AfterBuild">
|
||||||
|
<Copy SourceFiles="$(MSBuildProjectDirectory)\$(OutputPath)\TBConsole.dll" DestinationFolder="$(MSBuildProjectDirectory)\..\..\ref\Plugins" />
|
||||||
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -34,6 +34,9 @@ namespace TBConsole
|
||||||
{
|
{
|
||||||
var context = await _listener.GetContextAsync();
|
var context = await _listener.GetContextAsync();
|
||||||
string resp = await _receiver(await new StreamReader(context.Request.InputStream).ReadToEndAsync());
|
string resp = await _receiver(await new StreamReader(context.Request.InputStream).ReadToEndAsync());
|
||||||
|
string origin = context.Request.Headers["Origin"];
|
||||||
|
if (origin == "http://localhost:4200" || origin == "https://tbconsole.web.app")
|
||||||
|
context.Response.AddHeader("Access-Control-Allow-Origin", origin);
|
||||||
var sw = new StreamWriter(context.Response.OutputStream);
|
var sw = new StreamWriter(context.Response.OutputStream);
|
||||||
await sw.WriteLineAsync(resp);
|
await sw.WriteLineAsync(resp);
|
||||||
sw.Close();
|
sw.Close();
|
||||||
|
|
Loading…
Reference in a new issue