4

A client I'm working with has an internal API built that they use for search purposes, now API URLs are being built like this:

website/internal-api/sitecore/controller/method

My Question is if there is a way to hide the /sitecore part, as to hide the platform used by them.

  • 1
    how did they setup the routing? – Richard Seal May 9 '17 at 16:52
  • They changed the Speak.Mvc.CommandRoutePrefix to "internal-api/sitecore" and have multiple routes registered for different API calls within the RouteConfig.cs fle – Muradious May 9 '17 at 17:15
  • This is a little off topic; but why do you want to hide the platform? It'll most likely still be recognized by CMS detection tools and it's not like it adds security. – Jarmo Jarvi May 10 '17 at 20:34
  • It's more of a matter of a client request than it is what I want – Muradious May 10 '17 at 20:36
3

With WebAPI you may define your custom controller routes using Route attribute. The controller below excludes the /sitecore prefix from the URL and accessible as <hostname>/api/my:

[RoutePrefix("api/my")]
public class MyController : ServicesApiController
{
    [HttpGet]
    [Route]
    public string Get()
    {
        return DateTime.Now.ToString();
    }
}
| improve this answer | |
2

As I see it, your options are:

  1. Change the routing setup to remove the /sitecore part from the expected route information. Not knowing your code, this could have side effects and would need a thorough regression test.

  2. Using your Load Balancer (LB) or Url Rewrite rules, you can rewrite the public Url to remove the /sitecore part, and then route that from the LB to your servers. Again without specifics on your setup, the details on how to do this would vary depending on what LB you are using etc...

Personally I would go with the first option as it will be less confusing in the future.

| improve this answer | |
  • I'm sorry, I meant to have controller instead of the second api within the URL, does that make a difference? – Muradious May 10 '17 at 8:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.