Can I use API Gateway as a proxy to redirect a Rest API from a site to another?

0

HI Everyone, I'm still learning AWS and have a case scenario that I need to understand if it is possible to accomplish using API Gateway.

The company I am working with, has an e-commerce site built with Magento, and they are about to migrate to a WooCommerce site. I have been working on their mobile app that uses the Magento Rest API to login the customer and fetch content from the customer's account.

We are aware that a significant amount of our customers, that use our mobile app, do not have automatic update and do not update the app frequently. So we need to create a solution so that the old API's will redirect to the new ones.

Most of the API's are GET requests with params, but the login one is a POST as it uses the body to pass the username(Email) and password. So I'm trying to understand if it is possible to use API Gateway as a proxy to redirect the requests with the headers and respective body's so the users that won't update the app can still use it without being forced to update immediately. Giving us at least time to reach out and convince them to update.

Is this something that is possible? And if so could any one give me a idea of the flow please?

Many many thanks for the help.

Pedro-G
asked a year ago3710 views
1 Answer
0

Redirect may not be ideal for a REST API. If the API operations are similar and map 1:1 to the new API operations, you could proxy directly within API Gateway.

The flow to set this up would be:

  1. For each API operation in the old API determine which API operation in the new API to target
  2. In each API operation Integration Request settings, point to the new API operation using HTTP endpoint
  3. Any header, path parameter, query strings mapping or changes can be accomplished in the Integration Request in a mapping template
  4. Any POST Body adjustments can be accomplished in the Integration Request in a mapping template
  5. Any needs to map Response headers, body, or type can be accomplished in the Integration Response
profile picture
answered a year ago
  • Thank you for the answer cyrk-aws. And then what do I need to do in my old site so it knows the request should go to API Gateway?

  • The approach I described will work if the old API is in API Gateway. This way you control what the backend integration points to and make the changes to point to another API.

    If you don't have control over the old API then you will need to modify the old app/site to point to the new API. But that doesn't help your problem of users not updating the app.

  • Thank you so much cyrk-aws, To elaborate a little more, our old APIs are in Magento at them moment... our domain is set to point to the magento site, we will then change the domain to point to the new wordpress site...so for example....

    Currently the login API is www.ourdomain.com/rest/v1/login/token

    Our new API, once we change the domain to point there will be www.ourdomain.com/wp-json/jwt-auth/token

    I'm assuming that after the domain is changed to point to the new website the old API will try to go to the new site right?

    So i would need the www.ourdomain.com/rest/v1/login/token gets redirected with header and body to www.ourdomain.com/wp-json/jwt-auth/token

    So no API are managed through API Gateway. Does that help understand my situation better? Would this work?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions