Skip to content

This repository contains a streamlined Firebase Cloud Function that effortlessly directs users to the correct Amazon Store (like amazon.com, amazon.fr, amazon.de, etc.). This function is particularly useful for guiding customers to write reviews on the Amazon Store relevant to their region.

Notifications You must be signed in to change notification settings

bjoerndotsol/amazon-review-redirect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Redirect Cloud Function for Amazon Ratings

This repository contains a Firebase Cloud Function designed to perform geographical redirection based on the user's IP address. It's particularly useful for redirecting users to domain-specific pages or services, ensuring that they reach the most relevant content based on their location.

You can deploy this function and once a user, who bought a book on Amazon clicks on the link, they will be reidrected to the correct Amazon Store (US, DE, FR, ...) based on their IP address or langauge. Default always forwards to amazon.com

Tip: Use a QR code so the user can scan even easier.

Functionality

The geoRedirect function:

  • Checks if the domain making the request is allowed.
  • Retrieves the user's IP address.
  • Determines the user's geographical location using the geoip-lite library.
  • Redirects the user to a specific URL based on their country, with a fallback to a default domain.

Setup

Prerequisites

  • Node.js
  • Firebase CLI
  • A Firebase project

Installation

  1. Clone the repository:

    git clone https://github.com/bjoentrepreneur/amazon-review-redirect.git
    cd amazon-review-redirect
  2. Navigate to the functions directory:

   cd functions
  1. Istall dependencies:
   npm install

Configuration

  • Update the allowedDomains array in the index.js file to include the domains that are allowed to access this function.
  • Modify the countryDomainMapping object to map countries to specific domains as needed.

Deployment

Deploy the function to Firebase using the following command:

firebase deploy --only functions

Usage

Make a request to the deployed function's URL with the appropriate headers and query parameters:

  • x-forwarded-for: User's IP address.
  • asin: The Amazon Standard Identification Number.
  • language: (Optional) Fallback language parameter.

Disclaimer

This project is not affiliated with or endorsed by Amazon or any other domain-specific services used in the function.

Contributing

Contributions, issues, and feature requests are welcome. Feel free to check Issues if you want to contribute.

License

MIT

Contact

For any queries or contributions, please contact Björn

About

This repository contains a streamlined Firebase Cloud Function that effortlessly directs users to the correct Amazon Store (like amazon.com, amazon.fr, amazon.de, etc.). This function is particularly useful for guiding customers to write reviews on the Amazon Store relevant to their region.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published