Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

CORS policy: Request header field abp.tenantid is not allowed by Access-Control-Allow-Headers in preflight response. #10783


User avatar
0
KarakTheWise created

Greetings,

I know we've been trying to take care of this via email but as my emails are not getting through, I thought I post here. I really need help with this. I can send TeamViewer login data. I just need some direction as to where since, as I said, my emails are not getting through.

Access to XMLHttpRequest at 'http://karakthemad//AbpUserConfiguration/GetAll?d=1640727457038' from origin 'http://karakthemad:4500' has been blocked by CORS policy: Request header field abp.tenantid is not allowed by Access-Control-Allow-Headers in preflight response.

I've tried various Access-Control settings This is my current setup and still does not work: And I would prefer to not have a wild card for the origin.

&lt;customHeaders> <add name="Access-Control-Allow-Origin" value="*" /> &lt;add name="Access-Control-Allow-Headers" value="Origin, Content-Type,  X-Auth-Token" /> &lt;add name="Access-Control-Allow-Methods" value="HEAD, GET, POST, PUT, DELETE, PATCH, OPTIONS" /> &lt;/customHeaders>

From appsettings.production.json: "App": { "ServerRootAddress": "http://KarakTheMad:80/", "ClientRootAddress": "http://KarakTheMad:4500/", "CorsOrigins": "http://KarakTheMad/" }

I tried removing port 80 in the CorsOrigin as suggested in an older post. No luck.

The .NET Core app and the Angular app are in two separate projects and thus two separate IIS sites.

What do you need me to get setup for you when you do the TeamViewer session so I can have folders open etc. so you don't have to hunt around for them.

Thanks once again!


5 Answer(s)
  • User Avatar
    0
    KarakTheWise created

    Just so I this posted here and not lost in the email void, I'm also done the following:

    1.) I've installed IIS CORS 2.) I've added some of cors xml attributes to the web.config: &lt;cors enabled="true" failUnlistedOrigins="true"> <add origin="*" /> <add origin="http://karakthemad:4500"                  allowCredentials="true"                  maxAge="120"> &lt;allowHeaders allowAllRequestedHeaders="true"> &lt;add header="header1" /> &lt;add header="header2" /> &lt;add header="abp.tenantid" /> &lt;/allowHeaders> &lt;allowMethods> &lt;add method="GET" /> &lt;add method="HEAD" /> &lt;add method="POST" /> &lt;add method="PUT" /> &lt;add method="DELETE" /> &lt;/allowMethods> &lt;exposeHeaders> &lt;add header="header1" /> &lt;add header="header2" /> &lt;/exposeHeaders> &lt;/add> &lt;/cors>

    At his point I'm getting: GET http://karakthemad/Error?statusCode=404 500 (Internal Server Error) scripts.9470d603b68735921d8d.js:1 WARN: scripts.9470d603b68735921d8d.js:1 Could not find localization source: AbpWeb

    I tried adding part of the web.config from the Angular UI to the bottom of the existing web.config: &lt;staticContent> &lt;remove fileExtension=".json" /> <mimeMap fileExtension=".json" mimeType="application/json" /> <mimeMap fileExtension="woff" mimeType="application/font-woff" /> <mimeMap fileExtension="woff2" mimeType="application/font-woff" /> &lt;/staticContent> &lt;!-- IIS URL Rewrite for Angular routes --> &lt;rewrite> &lt;rules> &lt;rule name="Angular Routes" stopProcessing="true"> <match url=".*" /> &lt;conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" /> &lt;/conditions> <action type="Rewrite" url="/" /> &lt;/rule> &lt;/rules> &lt;/rewrite> When I do get an for index.html <span class="colour" style="color: rgb(34, 34, 34);">I get a "too many rewrites error".</span> Anyway, I've emailed all of this plus my TeamViewer info a little while ago.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @KarakTheWise

    We have sent you an email about this. Could you please check;

    1. Try to open the URL below in a new browser tab and see if it works.
    2. If it works or not, go to your deployed server side app's root folder and open App_Data/Logs folder and see error logs in Logs.txt file and share it with us.
  • User Avatar
    0
    KarakTheWise created

    Well, I would but I do not have an App_Data folder in my production application. I'm not sure what else to say about that. As far as going to that Url, I get this error: I'm responding to the related email with the TeamViewer information.

  • User Avatar
    0
    KarakTheWise created

    I sent an email with the TeamView information just now. Thanks again!

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @KarakTheWise

    Thanks, replied to your email. I assume the problem is, your angular app's configuration is wrong. We will provide a correct configuration according to your reply.