Skip to content

Commit

Permalink
fix for CORS
Browse files Browse the repository at this point in the history
  • Loading branch information
morozyan committed Jun 23, 2023
1 parent 9ce70e0 commit ab5b085
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/EsMxSimulator.NumberApp/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
using EsMxSimulator.Core.Services;
using EsMxSimulator.Core.Models;
using System.Web.Http;
using Microsoft.Net.Http.Headers;

namespace EsMxSimulator.NumberApp;

public class Generator
{
private const string GuessedNumberHeaderName = "guessed_number";

private readonly INumberSimulator _numberSimulator;

public Generator(INumberSimulator numberSimulator)
Expand All @@ -37,7 +40,9 @@ public async Task<IActionResult> Run(
try
{
result = await _numberSimulator.GuessNumber(0, endNumber);
req.HttpContext.Response.Headers.Add("guessed_number", result.Number.ToString());

req.HttpContext.Response.Headers.Add(HeaderNames.AccessControlExposeHeaders, GuessedNumberHeaderName);
req.HttpContext.Response.Headers.Add(GuessedNumberHeaderName, result.Number.ToString());
}
catch (Exception e)
{
Expand Down

0 comments on commit ab5b085

Please sign in to comment.