{"id":945,"date":"2020-11-03T00:58:10","date_gmt":"2020-11-02T15:58:10","guid":{"rendered":"https:\/\/www.typea.info\/blog\/?p=945"},"modified":"2020-11-03T00:59:04","modified_gmt":"2020-11-02T15:59:04","slug":"google_cloud_functions_cusgtom_domain","status":"publish","type":"post","link":"https:\/\/www.typea.info\/blog\/index.php\/2020\/11\/03\/google_cloud_functions_cusgtom_domain\/","title":{"rendered":"Google Cloud Functions \u306b \u30ab\u30b9\u30bf\u30e0\u30c9\u30e1\u30a4\u30f3\u3092\u8a2d\u5b9a\u3059\u308b"},"content":{"rendered":"<p>\u00a0<\/p>\n<p><a href=\"https:\/\/www.amazon.co.jp\/GCP%E3%81%AE%E6%95%99%E7%A7%91%E6%9B%B8II-%E3%80%90%E3%82%B3%E3%83%B3%E3%83%86%E3%83%8A%E9%96%8B%E7%99%BA%E7%B7%A8%E3%80%91-Kubernetes%E3%81%A8GKE%E3%80%81Cloud-Run%E3%80%81%E3%82%B5%E3%83%BC%E3%83%93%E3%82%B9%E3%83%A1%E3%83%83%E3%82%B7%E3%83%A5%E3%82%92%E8%A9%B3%E8%A7%A3-%E3%82%AF%E3%83%A9%E3%82%A6%E3%83%89%E3%82%A8%E3%83%BC%E3%82%B9%E6%A0%AA%E5%BC%8F%E4%BC%9A%E7%A4%BE\/dp\/4865942416\/ref=as_li_ss_il?__mk_ja_JP=%E3%82%AB%E3%82%BF%E3%82%AB%E3%83%8A&amp;crid=23JP9MIACZR0X&amp;dchild=1&amp;keywords=gcp%E3%81%AE%E6%95%99%E7%A7%91%E6%9B%B8&amp;qid=1604332104&amp;sprefix=GCP,aps,296&amp;sr=8-3-spons&amp;psc=1&amp;spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUExUzJOVFNDSjc3MExXJmVuY3J5cHRlZElkPUEwMjAzNTg1MkM3UlRYU1FPSkVQQiZlbmNyeXB0ZWRBZElkPUEyWEk2UVVQWVpRTkNHJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==&amp;linkCode=li2&amp;tag=typea09-22&amp;linkId=b646fb7ff84ce531d34537cd39a3a0cc&amp;language=ja_JP\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" src=\"\/\/ws-fe.amazon-adsystem.com\/widgets\/q?_encoding=UTF8&amp;ASIN=4865942416&amp;Format=_SL160_&amp;ID=AsinImage&amp;MarketPlace=JP&amp;ServiceVersion=20070822&amp;WS=1&amp;tag=typea09-22&amp;language=ja_JP\" border=\"0\" \/><\/a><img loading=\"lazy\" decoding=\"async\" style=\"border: none !important; margin: 0px !important;\" src=\"https:\/\/ir-jp.amazon-adsystem.com\/e\/ir?t=typea09-22&amp;language=ja_JP&amp;l=li2&amp;o=9&amp;a=4865942416\" alt=\"\" width=\"1\" height=\"1\" border=\"0\" \/><\/p>\n<p>\u00a0<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2020\/10\/30\/google_cloud_functions_express\/\">Google Cloud Functions \u306b Express \u3092\u9069\u7528<\/a>\u3067\u304d\u305f\u306e\u3067\u3001API\u3068\u3057\u3066\u547c\u3073\u51fa\u305b\u308b\u3088\u3046\u306b\u3057\u305f\u3044\u3002\u3002\u306e\u3060\u3051\u308c\u3069\u3001Functions\u306e\u30e1\u30cb\u30e5\u30fc\u306b\u30ab\u30b9\u30bf\u30e0\u30c9\u30e1\u30a4\u30f3\u3092\u8a2d\u5b9a\u3067\u304d\u305d\u3046\u306a\u30e1\u30cb\u30e5\u30fc\u304c\u306a\u3044\u3002\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"google_cloud_functions_url.png\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2020\/11\/google_cloud_functions_url.png\" alt=\"google_cloud_functions_url\" width=\"495\" height=\"219\" border=\"0\" \/><\/p>\n<h3>1.Google Cloud Functions \u306b\u30ab\u30b9\u30bf\u30e0\u30c9\u30e1\u30a4\u30f3\u3092\u8a2d\u5b9a\u3059\u308b<\/h3>\n<p><a href=\"https:\/\/firebase.google.com\/docs\/hosting\/full-config?hl=ja#rewrites\">\u3069\u3046\u3084\u3089\u3001Cloud Hosting \u306e \u30ea\u30e9\u30a4\u30c8\u3092\u69cb\u6210\u3057\u3066\u5b9f\u73fe\u3059\u308b\u3088\u3046\u3060<\/a>\u3002<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2020\/10\/30\/google_cloud_functions_express\/\">Express \u3092\u5c0e\u5165<\/a>\u3057\u305f\u306e\u3067\u3001\u9069\u5f53\u306aAPI\u3092\u5b9f\u88c5\u3057\u305f\u30eb\u30fc\u30bf\u30fc\u3092\u6e96\u5099(\u4e0b\u8a18 cocomoRouter ) \u3057\u305f\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<p><a href=\"https:\/\/firebase.google.com\/docs\/hosting\/full-config?hl=ja#glob_pattern_matching\">Glob\u30d1\u30bf\u30fc\u30f3\u30de\u30c3\u30c1\u30f3\u30b0<\/a>\u3092\u4f7f\u7528\u3057\u3066\u3001\/api\/** \u306b\u30de\u30c3\u30c1\u3057\u305f\u5834\u5408\u3001\u4ee5\u4e0b\u306eFunctions (apiService)\u3000\u306b\u98db\u3070\u3059\u3088\u3046\u306b\u8a2d\u5b9a\u3059\u308b\u3002<\/p>\n<p>(\u6700\u521d\u3001\/api\/**\u3000\u3067\u3001export \u00a0const api = functions.https.onRequest(app); \u306b\u98db\u3070\u3059\u3088\u3046\u306b\u3057\u3066\u3044\u305f\u3089\u3001\u5b9f\u969b\u306e\u30d1\u30b9\u304c\u3001\/api\/api\/\u2026 \u306a\u3069\u3068\u306a\u3063\u3066\u3057\u307e\u3044\u3001\u3046\u307e\u304f\u52d5\u304b\u306a\u304b\u3063\u305f\u306e\u3067)<\/p>\n<h4>1.1 Express\u306b\u3088\u308bAPI\u306e\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8<\/h4>\n<p>index.ts<\/p>\n<pre class=\"prettyprint\">import * as functions from 'firebase-functions';\nimport * as express from 'express';\nimport cocomoRouter from '.\/routes\/cocomo';\n\nconst app: express.Express = express();\n\nconst router: express.Router = express.Router()\napp.use(router);\napp.use('\/api\/cocomo', cocomoRouter);\n\nrouter.get('\/api\/test', (req, res) =&gt; {\n    res.send('TEST!');\n});\n\nexport const apiService = functions.https.onRequest(app);\n<\/pre>\n<p>\u00a0<\/p>\n<h4>1.2 firebase.json\u30ea\u30e9\u30a4\u30c8\u8a2d\u5b9a<\/h4>\n<p>firebase.json \u306b\u3001\u30ea\u30e9\u30a4\u30c8\u3059\u308b\u8a2d\u5b9a\u3092\u66f8\u304f\u3002<\/p>\n<ul>\n<li>\u30ea\u30e9\u30a4\u30c8\u306e\u30eb\u30fc\u30eb\u306f\u3001\u4e0a\u304b\u3089\u9806\u306b\u9069\u7528\u3055\u308c\u308b\u3088\u3046\u306a\u306e\u3067\u9806\u5e8f\u304c\u91cd\u8981\u3002<\/li>\n<li>\u4eca\u56de\u306f\u3082\u3068\u3082\u3068\u5b58\u5728\u3057\u3066\u3044\u305f\u3001\u5168\u3066\u3001index.html \u306b\u6d41\u3059\u30eb\u30fc\u30eb\u306e\u524d\u306b\u3001api\u306b\u6d41\u3059\u30eb\u30fc\u30eb\u3092\u8ffd\u52a0<\/li>\n<\/ul>\n<pre class=\"prettyprint\">{\n      : \u7701\u7565\n  \"hosting\": [\n    {\n\u3000\u3000\u3000\u3000\u3000  : \u7701\u7565\n      \"rewrites\": [\n        {\n          \"source\": \"\/api\/**\",\n          \"function\": \"apiService\"\n        },\n        {\n          \"source\": \"**\",\n          \"destination\": \"\/index.html\"\n        }\n      ]\n    }\n  ]\n}<\/pre>\n<h4>1.3 \u30a8\u30df\u30e5\u30ec\u30fc\u30bf\u3067\u52d5\u4f5c\u78ba\u8a8d<\/h4>\n<p>\u3067\u3001\u3053\u306e\u8fba\u308a\u306e\u6319\u52d5\u306e\u78ba\u8a8d\u3092\u884c\u3046\u306e\u306b\u306f\u3001\u30ed\u30fc\u30ab\u30eb\u3067\u30a8\u30df\u30e5\u30ec\u30fc\u30bf\u3092\u8d77\u52d5\u3057\u78ba\u8a8d<\/p>\n<p>$ firebase emulators:start<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"firebase_emulator.png\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2020\/11\/firebase_emulator.png\" alt=\"Firebase \u30a8\u30df\u30e5\u30ec\u30fc\u30bf\" width=\"519\" height=\"317\" border=\"0\" \/><\/p>\n<p>\u00a0<\/p>\n<h4>1.4 \u30ab\u30b9\u30bf\u30e0\u30c9\u30e1\u30a4\u30f3\u306e\u8a2d\u5b9a<\/h4>\n<p>\u30ab\u30b9\u30bf\u30e0\u30c9\u30e1\u30a4\u30f3\u306f\u3001Hosting\u306b\u5bfe\u3057\u3066\u5b9f\u65bd\u3059\u308b\u3002<\/p>\n<p>Firebase\u30b3\u30f3\u30bd\u30fc\u30eb\u306eHosting\u304b\u3089\u3001\u5bfe\u8c61\u306eHosging\u3092\u9078\u629e\u3057\u3001\u30ab\u30b9\u30bf\u30e0\u30c9\u30e1\u30a4\u30f3\u3092\u8ffd\u52a0\u30dc\u30bf\u30f3\u62bc\u4e0b<\/p>\n<p>\u5f8c\u306f\u3001\u30c9\u30e1\u30a4\u30f3\u306eDNS\u306b\u6307\u793a\u306b\u5f93\u3044\u3001A\u30ec\u30b3\u30fc\u30c9\u306e\u767b\u9332\u306a\u3069\u3092\u5b9f\u65bd<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"hosting_custom_domain_png.png\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2020\/11\/hosting_custom_domain_png.png\" alt=\"Hosting \u30ab\u30b9\u30bf\u30e0\u30c9\u30e1\u30a4\u30f3\" width=\"599\" height=\"213\" border=\"0\" \/><\/p>\n<h3>2.\u5b9f\u884c\u78ba\u8a8d\u3059\u308b<\/h3>\n<p>\u30ab\u30b9\u30bf\u30e0\u30c9\u30e1\u30a4\u30f3\u3001+\u3000\/api\/test \u3067\u60f3\u5b9a\u3069\u304a\u308a\u51e6\u7406\u3055\u308c\u305f\u7d50\u679c\u304c\u8868\u793a\u3055\u308c\u305f\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"firebase_function_custom_domain_api_test.png\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2020\/11\/firebase_function_custom_domain_api_test.png\" alt=\"\u30ab\u30b9\u30bf\u30e0\u30c9\u30e1\u30a4\u30f3 API\u30c6\u30b9\u30c8\" width=\"432\" height=\"177\" border=\"0\" \/><\/p>\n<p>\u00a0<\/p>\n<p>Express\u306e\u30eb\u30fc\u30bf\u30fc\u3092\u4f5c\u6210\u3057\u305fAPI\u306e\u547c\u3073\u51fa\u3057\u3082\u671f\u5f85\u3069\u304a\u308a\u52d5\u4f5c\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"hosting_custom_domain_cocomo.png\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2020\/11\/hosting_custom_domain_cocomo.png\" alt=\"API \u30c6\u30b9\u30c8\u547c\u3073\u51fa\u3057\" width=\"598\" height=\"301\" border=\"0\" \/><\/p>\n<p>2\u6642\u9593\u304f\u3089\u3044\u3001\u8a2d\u5b9a\u306b\u60a9\u3093\u3060\u3051\u3069\u3001\u671f\u5f85\u3069\u304a\u308a\u306b\u52d5\u4f5c\u3059\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0 \u00a0 Google Cloud Functions \u306b Express \u3092\u9069\u7528\u3067\u304d\u305f\u306e\u3067\u3001API\u3068\u3057\u3066\u547c\u3073\u51fa\u305b\u308b\u3088\u3046\u306b\u3057\u305f\u3044\u3002\u3002\u306e\u3060\u3051\u308c\u3069\u3001Functions\u306e\u30e1\u30cb\u30e5\u30fc\u306b\u30ab\u30b9\u30bf\u30e0\u30c9\u30e1\u30a4\u30f3\u3092\u8a2d\u5b9a\u3067\u304d\u305d\u3046\u306a\u30e1\u30cb\u30e5\u30fc\u304c\u306a\u3044\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":944,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"","vkexunit_cta_each_option":"","footnotes":""},"categories":[118,112],"tags":[],"class_list":["post-945","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-express","category-google-cloud-functions"],"veu_head_title_object":{"title":"","add_site_title":""},"_links":{"self":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/945","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=945"}],"version-history":[{"count":2,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/945\/revisions"}],"predecessor-version":[{"id":947,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/945\/revisions\/947"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/media\/944"}],"wp:attachment":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=945"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=945"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=945"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}