Browse Source

Fixed CDN not checking the right headers

tags/3.0.0
Teknikode 2 years ago
parent
commit
951635fcbe
1 changed files with 9 additions and 2 deletions
  1. 9
    2
      Teknik/Modules/CORSModule.cs

+ 9
- 2
Teknik/Modules/CORSModule.cs View File

@@ -24,9 +24,16 @@ namespace Teknik.Modules
string origin = (requestContext.Request.IsLocal) ? "*" : requestContext.Request.Headers.Get("Origin");

// Is the referrer set to the CDN and we are using a CDN?
if (config.UseCdn && requestContext.Request.Headers.Get("Referer") == config.CdnHost)
if (config.UseCdn && !string.IsNullOrEmpty(config.CdnHost))
{
origin = requestContext.Request.Headers.Get("Host");
try
{
string host = requestContext.Request.Headers.Get("Host");
Uri uri = new Uri(config.CdnHost);
if (host == uri.Host)
origin = host;
}
catch { }
}

string domain = (string.IsNullOrEmpty(origin)) ? string.Empty : origin.GetDomain();

Loading…
Cancel
Save