Silently move api resources to another url

Viewed 828

I've got api written with WepApi 2 tightly coupled with main web site. I've decided to decouple it to another web app to keep things more isolated.

I've followed such steps:

  1. Extract all the API controllers to another project
  2. Creat attribute to redirect all the users currently using our old URL to the new one. For such reasons I've used 307 status code because we should keep user's request's verb and request payload.

        var response = request.CreateResponse(HttpStatusCode.TemporaryRedirect); //307
        response.Headers.Location = new Uri($"{appConfig.ApiAppDomain}" + "/" + request.RequestUri.AbsolutePath + request.RequestUri.Query);
        return response;
    

In common it works nice. Client got 307 and then follows to the URL in Location header.

The problem is here: the main web app is https and the new api is http. When I'm using postman it behave strange and do replace the POST request with GET request with all request's body cutting. Not good at all and strange because 307 doesn't allow to change the method and the payload.

So here are the couple of questions:

  1. What is the best way to handle this https -> http redirection?
  2. Whether it is good solution at all or not?
  3. What is the best solution to silently move our users to new api url?
1 Answers
Related