Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dakota Lightning 11 posts 42 karma points
    Nov 27, 2014 @ 23:01
    Dakota Lightning
    0

    Centralized Umbraco 7 Dashboards - Access-Control-Allow-Origin

    Hey guys,

    I don't know if this has been solved or not, I can't seem to find any documentation on it. In our environment we currently have about 6 Umbraco sites across the company. I created a portal to manage the user permissions for all the sites using Active Directory in a central location. I want to add a way to update the content for each site's Dashboard for the editors to read for changes, tips, and new features, etc.

    When I add http://portal.local/api/dashboard/StartupDashboardSection to the Dashboard.config I'm getting an Access-Control-Allow-Origin error which is to be expected.

    <dashBoard>
    
      <section alias="StartupDashboardSection">
        <areas>
          <area>content</area>
        </areas>
    
        <tab caption="Get Started">
          <control showOnce="false" addPanel="true" panelCaption="">
            http://portal.local/api/dashboard/StartupDashboardSection
          </control>
        </tab>
      </section>
    
    </dashBoard>
    

    Has anyone been able to solve this or a recommended setup? I can't get $sceDelegateProvider to work for some reason

    app.config(['$sceDelegateProvider', function ($sceDelegateProvider) {
        $sceDelegateProvider.resourceUrlWhitelist([
            'self',
            'http://*.wem.local/**'
        ]);
    }]);
    

    Any ideas?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Nov 28, 2014 @ 06:07
    Jan Skovgaard
    0

    Hi Dakota

    Perhaps this can shed a light on things? Someone says it's a chrome bug? http://stackoverflow.com/questions/21102690/angularjs-not-detecting-access-control-allow-origin-header

    /Jan

  • Dakota Lightning 11 posts 42 karma points
    Nov 28, 2014 @ 19:17
    Dakota Lightning
    1

    I would agree with you, however it doesn't work with IE or Firefox on the server none localhost.

    I have added the code below to app.js however this sets requests to OPTIONS which wont work since the portal is set to windows authentication and returns a 401 Unauthorized, which is to be expected. The Angualr side might not be able to create the handhake and authorize to use the Options verb on the API.

    app.config(['$httpProvider', function($httpProvider) {
            angular.extend($httpProvider.defaults.headers.common, {
                "Access-Control-Allow-Origin": "portal.local",
                "Access-Control-Allow-Methods": "GET, POST, OPTIONS"
            });
        }
    ]);
    

    After adding this to my web.config on the Portal, the only issue I have to solve is allowing the Umbraco Angular to authorize using Windows authentication when requesting the template.

    <httpProtocol>
      <customHeaders>
        <remove name="Cache-Control" />
        <add name="Access-Control-Allow-Origin" value="*" />
        <add name="Access-Control-Allow-Headers" value="Content-Type" />
        <add name="Access-Control-Allow-Methods" value="GET, OPTIONS" />
      </customHeaders>
    </httpProtocol>
    
Please Sign in or register to post replies

Write your reply to:

Draft