0

I have one API and two different domain. How can I check which domain host triggered api request?

Example:

  • API: example.API.com
  • Domain1: example.Domain1.com
  • Domain2: example.Domain2.com

and I want to know which domain call my API?

I used C# for my code, maybe there is a ready way to solve my problem but if not then maybe some advice on how to approach the problem?

I try code.

string host = _httpContextAccessor.HttpContext?.Request.Headers.Referer.FirstOrDefault();

This code gives me the full url of the client, but I don't know if that's a good way because this can be null.

  • You have to check directly with the Request URI. See https://stackoverflow.com/questions/42547653/how-to-access-current-absolute-uri-from-any-asp-net-core-class – Eduardo Molteni Nov 07 '22 at 20:14

0 Answers0