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

CORS policy issues #7557


User avatar
0
cictan created

my host website is dobany.com, angular site is admin.dobany.com, I have aleady updated the setting like this: "App": { "ServerRootAddress": "http://dobany.com", "ClientRootAddress": "http://admin.dobany.com", "CorsOrigins": "http://*.dobany.com,http://localhost:4200,http://localhost:49152,http://admin.dobany.com", "SwaggerEndPoint": "/swagger/v1/swagger.json", "AllowAnonymousSignalRConnection": "true" },

But I still have issues:

  1. angular site works fine, I can see the data loaded, however, when I submitted email setting from the host setting page, the error messages showed: Access to XMLHttpRequest at 'http://dobany.com/api/services/app/HostSettings/UpdateAllSettings' from origin 'http://admin.dobany.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. polyfills.59c59ad684f93239a61e.js:1 PUT http://dobany.com/api/services/app/HostSettings/UpdateAllSettings net::ERR_FAILED

  2. When I refreshed the home page or loaded different pages, the cors policy issue showed occasionally


12 Answer(s)
  • User Avatar
    0
    cictan created

    I updated web.config and the updates worked:

    <system.webServer> <modules runAllManagedModulesForAllRequests="false"> <remove name="WebDAVModule" /> </modules> </system.webServer>

    However, I still see the issue showed occasionally

    Access to XMLHttpRequest at 'http://dobany.com/api/services/app/Account/ResolveTenantId' from origin 'http://admin.dobany.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. dobany.com/api/services/app/Account/ResolveTenantId:1 Failed to load resource: net::ERR_FAILED main.c435b59a98948a44e76d.js:1 ERROR Error: An unexpected server error occurred. at new t (main.c435b59a98948a44e76d.js:1) at to (main.c435b59a98948a44e76d.js:1) at t.project (main.c435b59a98948a44e76d.js:1) at t._tryNext (main.c435b59a98948a44e76d.js:1) at t._next (main.c435b59a98948a44e76d.js:1) at t.next (main.c435b59a98948a44e76d.js:1) at e._subscribe (main.c435b59a98948a44e76d.js:1) at e._trySubscribe (main.c435b59a98948a44e76d.js:1) at e.subscribe (main.c435b59a98948a44e76d.js:1) at e.call (main.c435b59a98948a44e76d.js:1)

  • User Avatar
    0
    cictan created

    I opened the dashboard page, the following error showed, I then refresh the page, the error disappeared and everything worked, any idea? :

    Access to XMLHttpRequest at 'http://dobany.com/api/services/app/HostDashboard/GetDashboardStatisticsData?IncomeStatisticsDateInterval=1&StartDate=2019-08-21T07%3A00%3A00.000Z&EndDate=2019-08-29T06%3A59%3A59.999Z' from origin 'http://app.dobany.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. polyfills.59c59ad684f93239a61e.js:1 GET http://dobany.com/api/services/app/HostDashboard/GetDashboardStatisticsData?IncomeStatisticsDateInterval=1&StartDate=2019-08-21T07%3A00%3A00.000Z&EndDate=2019-08-29T06%3A59%3A59.999Z net::ERR_FAILED T @ polyfills.59c59ad684f93239a61e.js:1 t.scheduleTask @ polyfills.59c59ad684f93239a61e.js:1 onScheduleTask @ polyfills.59c59ad684f93239a61e.js:1 t.scheduleTask @ polyfills.59c59ad684f93239a61e.js:1 e.scheduleTask @ polyfills.59c59ad684f93239a61e.js:1 e.scheduleMacroTask @ polyfills.59c59ad684f93239a61e.js:1 v @ polyfills.59c59ad684f93239a61e.js:1 (anonymous) @ polyfills.59c59ad684f93239a61e.js:1 A.i.<computed> @ polyfills.59c59ad684f93239a61e.js:1 (anonymous) @ main.c435b59a98948a44e76d.js:1 e._trySubscribe @ main.c435b59a98948a44e76d.js:1 e.subscribe @ main.c435b59a98948a44e76d.js:1 e.intercept @ main.c435b59a98948a44e76d.js:1 e.handle @ main.c435b59a98948a44e76d.js:1 e.intercept @ main.c435b59a98948a44e76d.js:1 e.handle @ main.c435b59a98948a44e76d.js:1 e.intercept @ main.c435b59a98948a44e76d.js:1 e.handle @ main.c435b59a98948a44e76d.js:1 e.handle @ main.c435b59a98948a44e76d.js:1 (anonymous) @ main.c435b59a98948a44e76d.js:1 t._tryNext @ main.c435b59a98948a44e76d.js:1 t._next @ main.c435b59a98948a44e76d.js:1 t.next @ main.c435b59a98948a44e76d.js:1 (anonymous) @ main.c435b59a98948a44e76d.js:1 e._trySubscribe @ main.c435b59a98948a44e76d.js:1 e.subscribe @ main.c435b59a98948a44e76d.js:1 e.call @ main.c435b59a98948a44e76d.js:1 e.subscribe @ main.c435b59a98948a44e76d.js:1 e.call @ main.c435b59a98948a44e76d.js:1 e.subscribe @ main.c435b59a98948a44e76d.js:1 e.call @ main.c435b59a98948a44e76d.js:1 e.subscribe @ main.c435b59a98948a44e76d.js:1 e.call @ main.c435b59a98948a44e76d.js:1 e.subscribe @ main.c435b59a98948a44e76d.js:1 n.getDashboardStatisticsData @ 8.48c9374a55a423eb696e.js:1 n.init @ 8.48c9374a55a423eb696e.js:1 n.ngOnInit @ 8.48c9374a55a423eb696e.js:1 (anonymous) @ main.c435b59a98948a44e76d.js:1 (anonymous) @ main.c435b59a98948a44e76d.js:1 qO @ main.c435b59a98948a44e76d.js:1 QO @ main.c435b59a98948a44e76d.js:1 (anonymous) @ 8.48c9374a55a423eb696e.js:1 updateDirectives @ main.c435b59a98948a44e76d.js:1 AO @ main.c435b59a98948a44e76d.js:1 CO @ main.c435b59a98948a44e76d.js:1 kO @ main.c435b59a98948a44e76d.js:1 AO @ main.c435b59a98948a44e76d.js:1 CO @ main.c435b59a98948a44e76d.js:1 TO @ main.c435b59a98948a44e76d.js:1 AO @ main.c435b59a98948a44e76d.js:1 CO @ main.c435b59a98948a44e76d.js:1 kO @ main.c435b59a98948a44e76d.js:1 AO @ main.c435b59a98948a44e76d.js:1 CO @ main.c435b59a98948a44e76d.js:1 TO @ main.c435b59a98948a44e76d.js:1 AO @ main.c435b59a98948a44e76d.js:1 CO @ main.c435b59a98948a44e76d.js:1 kO @ main.c435b59a98948a44e76d.js:1 AO @ main.c435b59a98948a44e76d.js:1 CO @ main.c435b59a98948a44e76d.js:1 TO @ main.c435b59a98948a44e76d.js:1 AO @ main.c435b59a98948a44e76d.js:1 e.detectChanges @ main.c435b59a98948a44e76d.js:1 e.tick @ main.c435b59a98948a44e76d.js:1 (anonymous) @ main.c435b59a98948a44e76d.js:1 t.invoke @ polyfills.59c59ad684f93239a61e.js:1 onInvoke @ main.c435b59a98948a44e76d.js:1 t.invoke @ polyfills.59c59ad684f93239a61e.js:1 e.run @ polyfills.59c59ad684f93239a61e.js:1 e.run @ main.c435b59a98948a44e76d.js:1 next @ main.c435b59a98948a44e76d.js:1 i @ main.c435b59a98948a44e76d.js:1 t.__tryOrUnsub @ main.c435b59a98948a44e76d.js:1 t.next @ main.c435b59a98948a44e76d.js:1 t._next @ main.c435b59a98948a44e76d.js:1 t.next @ main.c435b59a98948a44e76d.js:1 t.next @ main.c435b59a98948a44e76d.js:1 t.emit @ main.c435b59a98948a44e76d.js:1 Fm @ main.c435b59a98948a44e76d.js:1 onHasTask @ main.c435b59a98948a44e76d.js:1 t.hasTask @ polyfills.59c59ad684f93239a61e.js:1 t._updateTaskCount @ polyfills.59c59ad684f93239a61e.js:1 e._updateTaskCount @ polyfills.59c59ad684f93239a61e.js:1 e.runTask @ polyfills.59c59ad684f93239a61e.js:1 d @ polyfills.59c59ad684f93239a61e.js:1 e.invokeTask @ polyfills.59c59ad684f93239a61e.js:1 b @ polyfills.59c59ad684f93239a61e.js:1 m @ polyfills.59c59ad684f93239a61e.js:1 Show 58 more frames main.c435b59a98948a44e76d.js:1 ERROR Error: An unexpected server error occurred. at new t (main.c435b59a98948a44e76d.js:1) at to (main.c435b59a98948a44e76d.js:1) at t.project (main.c435b59a98948a44e76d.js:1) at t._tryNext (main.c435b59a98948a44e76d.js:1) at t._next (main.c435b59a98948a44e76d.js:1) at t.next (main.c435b59a98948a44e76d.js:1) at e._subscribe (main.c435b59a98948a44e76d.js:1) at e._trySubscribe (main.c435b59a98948a44e76d.js:1) at e.subscribe (main.c435b59a98948a44e76d.js:1) at e.call (main.c435b59a98948a44e76d.js:1)

  • User Avatar
    0
    maliming created
    Support Team

    You can view the backend logs, which may be helpful messages.

  • User Avatar
    0
    cictan created

    no, I kept looking at the backend logs, no useful messages.

  • User Avatar
    0
    maliming created
    Support Team

    Can you share the logs of your backend application?

    If there is privacy data please send it to: [email protected]

  • User Avatar
    0
    cictan created

    I've sent you the log, thanks

  • User Avatar
    0
    maliming created
    Support Team

    hi cictan

    I have confirmed that the problem will appear randomly, but the problem is not caused by cors. I didn't see any errors in the logs. Can you check the IIS logs or the windows event logs? Maybe there may be some information here.

    I will also report the problem to my colleague. :)

  • User Avatar
    0
    maliming created
    Support Team

    By the way, the admin default password for your website has not been modified. If you have important data, please remember to change your password.

  • User Avatar
    0
    cictan created

    Thanks, this is just a demo site. And also I found another strange issue today, the first time I loaded the angular home page(which will be the login page), it always reported CORS issue(of course, as you said, it was not caused by cors), and then I refreshed it, the issue was gone.

    No other site has the same issue before, it's just me? Thank you so much, I will look at the IIS logs.

  • User Avatar
    0
    maliming created
    Support Team

    Yes, I didn’t see any feedback that they encountered a random CORS problem.

  • User Avatar
    0
    cictan created

    Hi maliming, I have checked IIS logs and the windows event logs very carefully with the date time when the errors occurred, but found no information. Any other suggestions? or work around?

  • User Avatar
    0
    maliming created
    Support Team

    hi cictan

    1. You can try not to use IIS but use Kestrel. Exclude IIS issues.

    2. You can use Zero's Demo project to see if the above problem will also occur. If it happens, please share the steps to reproduce the problem. If the Demo project works fine, please check your code or share your code with us.