title: How to configure custom domain for Google Cloud Functions for rendering HTML
body: <p>So I have deployed a Google Cloud Function to some place like this:</p>
  
  <pre><code>https://us-central1-my-project.cloudfunctions.net/my-function
  </code></pre>
  
  <p>I can successfully render a dynamic webpage like this:</p>
  
  <pre><code>https://us-central1-my-project.cloudfunctions.net/my-function?slug=foo
  </code></pre>
  
  <p>Now, I would like to put this behind a regular URL so it works like this:</p>
  
  <pre><code>https://my-domain.com/some-directory/foo
  </code></pre>
  
  <p>I would like for it to be <strong>https</strong> instead of http. And notice that I added <code>some-directory</code> above the <code>foo</code> slug, so there is a little bit of rewriting logic there.</p>
  
  <p>So basically go from here to here:</p>
  
  <pre><code>https://us-central1-my-project.cloudfunctions.net/my-function?slug=foo
  https://my-domain.com/some-directory/foo
  </code></pre>
  
  <p>The question is how to do this. Wondering if you could walk me through how to do it which I think would also help future googlers.</p>
  
  <p>When I search "custom domain for google cloud function" I get <a href="https://cloud.google.com/endpoints/docs/openapi/dev-portal-setup-custom-domain" rel="noreferrer">this</a> which is for "endpoints" or "openapi" or I don't know, but it doesn't quite seem related. However, I went ahead anyways and changed my DNS nameservers to match what they said:</p>
  
  <pre><code>A     198.51.100.0
  A     198.51.100.2
  A     198.51.100.4
  A     198.51.100.6
  AAAA  2001:db8:ffff:32::15
  AAAA  2001:db8:ffff:34::15
  AAAA  2001:db8:ffff:36::15
  AAAA  2001:db8:ffff:38::15
  </code></pre>
  
  <p>But I am lost as to what to do next. The documentation for Google Cloud is nothing compared to AWS which is unfortunate.</p>
  
  <p><a href="https://stackoverflow.com/questions/45850375/use-custom-domain-for-google-cloud-function">This</a> is as close to what I've found so far, but it's still not even close to getting it working. Maybe <a href="https://medium.com/wellzesta/hot-url-mapping-using-cloud-functions-49dad256d663" rel="noreferrer">this</a> is closer to what I want.</p>