Skip to content

hlxsites/hsf-commonmoves

Repository files navigation

Your Project's Title...

Your project's description...

Environments

Installation

npm i

Linting

npm run lint

Local development

  1. Create a new repository based on the aem-boilerplate template and add a mountpoint in the fstab.yaml
  2. Add the AEM Code Sync GitHub App to the repository
  3. Install the AEM CLI: npm install -g @adobe/aem-cli
  4. Start AEM Proxy: aem up (opens your browser at http://localhost:3000)
  5. Open the {repo} directory in your favorite IDE and start coding :)

Local Proxy for APIs

There are numerous APIs that this site relies on, including but not limited to:

  • Account (login, profile, etc)
  • Blog
  • Properties (search, listing, etc)
  • Agent (details, search)
  • Suggestions

All of these APIs are hosted on an AMS system. To make use of them locally, a proxy is needed.

There are two ways to set up the local proxy:

  • Real Domain Proxy
    • Less configuration, but must be aware when proxy is/isn't running.
  • Local Proxy to Remote
    • More configuration, but explicit domain for proxy - clear delineation of live and proxied traffic.

Either way, you need to download and install a local proxy. These instructions use Proxyman. Once you download and install Proxyman, you will need to also install the Proxyman CA certs. These are needed to be able to route the secure traffic.

Real Domain Proxy

In this setup, the proxy is configured to route non-API traffic on the Staging domain to your local computer. So all requests except the APIs will go the local host. The API calls will remain routed to the Stage domain.

  1. Create a new Allow List entry:

    • Tools => Allow List
    • Name: BHHS Stage
    • Rule: https://stage.commonmoves.com*
    • Any, Use Wildcard
    • Include all subpaths of this URL: Checked
  2. Create a new Map Remote Entry:

    • Tools => Map Remote
    • Matching Rule:
      • Name: BHHS API
      • Rule: https://stage.commonmoves.com(?!(/bin|/content)).*
      • Any, Use Regex
      • Include all subpaths of this URL: Checked
    • Map To:
      • Protocol: http
      • Host: localhost
      • Port: 3000

Local Proxy to Remote

This setup uses a locally resolved domain, which will Proxyman will use to route the traffic. All non-API traffic will route to localhost, all API traffic will go to the Stage domain.

  1. Add an entry to /etc/maps: Proxyman won't proxy localhost, so a custom domain is required. Add the following (if you already have a host entry for 127.0.0.1, simply add the new domain)

127.0.0.1 proxyman.debug

  1. Create a self-signed cert. This is necessary for the AEM Cli to so that cookies can be persisted. It really doesn't matter what you answer for the questions. Just make sure you do not create the certs in the code repo, or add them to Git.

(/some/path is used as a reference here, find an appropriate spot on your local computer)

$ cd /some/path
$ openssl req -x509 -sha256 -nodes -newkey rsa:2048 -days 365 -keyout localhost.key -out localhost.crt
  1. Create a new Allow List entry:

    • Tools => Allow List
    • Name: Localhost
    • Matching Rule https:\/\/proxyman\.debug:\d+.*
    • Any, Use Regex
    • Include all subpaths of this URL: checked
  2. Create a new Map Remote Entry:

    • Tools => Map Remote
    • Matching Rule
      • Name: BHHS API
      • Rule: https://proxyman.debug:\d+(/bin|/content).*
      • Any, Use Regex
      • Include all subpaths of this URL: checked
    • Map To
      • Protocol: https
      • Host: stage.commonmoves.com
      • Port: 443
  3. Staring the AEM local proxy requires also passing in the Cert info, to run using https:

(/some/path is the same place you previously created the cert)

% aem up --tls-cert /some/path/localhost.crt --tls-key /some/path/localhost.key

To view Proxied site use: https://proxyman.debug:3000/

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published