Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate MAGENTO_BACKEND_URL at Runtime #4

Open
bbatsche opened this issue Jan 31, 2019 · 0 comments
Open

Generate MAGENTO_BACKEND_URL at Runtime #4

bbatsche opened this issue Jan 31, 2019 · 0 comments

Comments

@bbatsche
Copy link
Member

Venia Concept requires a MAGENTO_BACKEND_URL environment variable. This can be generated in one of three ways.

  1. From Magento's own configs. Look up web/secure/base_url or web/unsecure/base_url and set the value accordingly.

  2. From MAGENTO_CLOUD_ROUTES

The MAGENTO_CLOUD_ROUTES environment variable is the contains the live URLs Magento Cloud uses. We should use this data to set MAGENTO_BACKEND_URL before forwarding the request on to UPWARD & Venia.

The value of MAGENTO_CLOUD_ROUTES is base64 encoded JSON. Once decoded it looks like the following:

{
   "https://venia-test2-btfocsy-lnw62ehme7md2.us-4.magentosite.cloud/" : {
      "upstream" : "mymagento",
      "id" : null,
      "original_url" : "https://{default}/",
      "restrict_robots" : true,
      "type" : "upstream",
      "ssi" : {
         "enabled" : false
      },
      "primary" : false,
      "tls" : {
         "client_certificate_authorities" : [],
         "client_authentication" : null,
         "strict_transport_security" : {
            "preload" : null,
            "enabled" : null,
            "include_subdomains" : null
         },
         "min_version" : null
      },
      "cache" : {
         "headers" : [
            "Accept",
            "Accept-Language"
         ],
         "enabled" : true,
         "cookies" : [
            "*"
         ],
         "default_ttl" : 0
      }
   },
   "http://venia-test2-btfocsy-lnw62ehme7md2.us-4.magentosite.cloud/" : {
      "upstream" : "mymagento",
      "id" : null,
      "original_url" : "http://{default}/",
      "restrict_robots" : true,
      "ssi" : {
         "enabled" : false
      },
      "type" : "upstream",
      "primary" : true,
      "tls" : {
         "strict_transport_security" : {
            "enabled" : null,
            "preload" : null,
            "include_subdomains" : null
         },
         "client_authentication" : null,
         "client_certificate_authorities" : [],
         "min_version" : null
      },
      "cache" : {
         "default_ttl" : 0,
         "enabled" : true,
         "headers" : [
            "Accept",
            "Accept-Language"
         ],
         "cookies" : [
            "*"
         ]
      }
   }
}

Look through the JSON and pick the appropriate key (preferring https)

  1. Fallback on localhost (not 100% certain this will work)
mmansoor-magento pushed a commit that referenced this issue Nov 24, 2020
* Whitelist -> Allowlist

* Use inclusive language and add shipping as default value

* Add flag to easily restore default value

Co-authored-by: Revanth Kumar Annavarapu <35203638+revanth0212@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant