Copied to clipboard

Flag this post as spam?

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


  • Mark Wemekamp 73 posts 385 karma points
    Mar 29, 2018 @ 19:12
    Mark Wemekamp
    1

    Using umbRequestHelper getApiUrl with package specific urls

    I wan't to replace my hardcoded urls in my angular services with something more dynamic and found the our article on Server variables & URLs

    I've added a new eventhandler and implemented the Parsing method with the custom routes and to a dictionary item with the name of my package.

    dictionary.Add("package_name", new Dictionary<string, object>
    {
        {"Api", "url"}
    });
    

    When calling the Umbraco.Sys.ServerVariables["package_name"] the added variables show up.

    I was hoping I could use umbRequestHelper.getApiUrl to retrieve the urls, in my angular code, but after looking in the source code I see the getApiUrl is hardcoded to only look in Umbraco.Sys.ServerVariables["umbracoUrls"].

    So my question is, what is the correct way to have umbRequestHelper look for my custom routes in Umbraco.Sys.ServerVariables["package_name"]?

    For now I've added my own service with a literal copy of getApiUrl that looks in the custom Umbraco.Sys.ServerVariables["package_name"], so my code works but it feels hacky.

  • Søren Gregersen 441 posts 1884 karma points MVP 2x c-trib
    Mar 29, 2018 @ 19:56
    Søren Gregersen
    1

    I’ve done it the same way.

    Haven’t seen a more elegant solution.

Please Sign in or register to post replies

Write your reply to:

Draft