{"id":249,"date":"2021-04-23T17:12:11","date_gmt":"2021-04-23T17:12:11","guid":{"rendered":"https:\/\/www.369usa.com\/blog\/?p=249"},"modified":"2021-04-23T17:12:11","modified_gmt":"2021-04-23T17:12:11","slug":"local-https-server","status":"publish","type":"post","link":"https:\/\/www.369usa.com\/blog\/local-https-server\/","title":{"rendered":"Local HTTPS server"},"content":{"rendered":"<pre>\r\n\r\nconst express = require('express');\r\nconst path = require('path');\r\nconst https = require('https');\r\nconst http = require('http');\r\nconst fs = require('fs');\r\nconst app = express();\r\n\r\nconst credentials = {\r\n    key: fs.readFileSync('.\/.cert\/key.pem'),\r\n    cert: fs.readFileSync('.\/.cert\/cert.pem')\r\n  };\r\n\r\napp.use(express.static(path.join(__dirname, 'build')));\r\n\r\napp.get('\/', function (req, res) {\r\n  res.sendFile(path.join(__dirname, 'build', 'index.html'));\r\n});\r\n\r\nvar httpServer = http.createServer(app);\r\nvar httpsServer = https.createServer(credentials, app);\r\n\r\nhttpServer.listen(3001);\r\nhttpsServer.listen(443);\r\n\r\nconsole.log('server is listening ...')\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>const express = require(&#8216;express&#8217;); const path = require(&#8216;path&#8217;); const https = require(&#8216;https&#8217;); const http = require(&#8216;http&#8217;); const fs = require(&#8216;fs&#8217;); const app = express(); const credentials = { key: fs.readFileSync(&#8216;.\/.cert\/key.pem&#8217;), cert: fs.readFileSync(&#8216;.\/.cert\/cert.pem&#8217;) }; app.use(express.static(path.join(__dirname, &#8216;build&#8217;))); app.get(&#8216;\/&#8217;, function (req, res) { res.sendFile(path.join(__dirname, &#8216;build&#8217;, &#8216;index.html&#8217;)); }); var httpServer = http.createServer(app); var httpsServer = https.createServer(credentials, app); httpServer.listen(3001); httpsServer.listen(443); &hellip; <a href=\"https:\/\/www.369usa.com\/blog\/local-https-server\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Local HTTPS server&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-249","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Local HTTPS server - \u7ebd\u7ea6\u7f51\u7ad9\u8bbe\u8ba1\u535a\u5ba2<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.369usa.com\/blog\/local-https-server\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Local HTTPS server - \u7ebd\u7ea6\u7f51\u7ad9\u8bbe\u8ba1\u535a\u5ba2\" \/>\n<meta property=\"og:description\" content=\"const express = require(&#039;express&#039;); const path = require(&#039;path&#039;); const https = require(&#039;https&#039;); const http = require(&#039;http&#039;); const fs = require(&#039;fs&#039;); const app = express(); const credentials = { key: fs.readFileSync(&#039;.\/.cert\/key.pem&#039;), cert: fs.readFileSync(&#039;.\/.cert\/cert.pem&#039;) }; app.use(express.static(path.join(__dirname, &#039;build&#039;))); app.get(&#039;\/&#039;, function (req, res) { res.sendFile(path.join(__dirname, &#039;build&#039;, &#039;index.html&#039;)); }); var httpServer = http.createServer(app); var httpsServer = https.createServer(credentials, app); httpServer.listen(3001); httpsServer.listen(443); &hellip; Continue reading &quot;Local HTTPS server&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.369usa.com\/blog\/local-https-server\/\" \/>\n<meta property=\"og:site_name\" content=\"\u7ebd\u7ea6\u7f51\u7ad9\u8bbe\u8ba1\u535a\u5ba2\" \/>\n<meta property=\"article:published_time\" content=\"2021-04-23T17:12:11+00:00\" \/>\n<meta name=\"author\" content=\"darkersss\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"darkersss\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.369usa.com\/blog\/local-https-server\/\",\"url\":\"https:\/\/www.369usa.com\/blog\/local-https-server\/\",\"name\":\"Local HTTPS server - \u7ebd\u7ea6\u7f51\u7ad9\u8bbe\u8ba1\u535a\u5ba2\",\"isPartOf\":{\"@id\":\"https:\/\/www.369usa.com\/blog\/#website\"},\"datePublished\":\"2021-04-23T17:12:11+00:00\",\"dateModified\":\"2021-04-23T17:12:11+00:00\",\"author\":{\"@id\":\"https:\/\/www.369usa.com\/blog\/#\/schema\/person\/1c260c42af4aadda7f89a0081f6591b6\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.369usa.com\/blog\/local-https-server\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.369usa.com\/blog\/local-https-server\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.369usa.com\/blog\/local-https-server\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.369usa.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Local HTTPS server\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.369usa.com\/blog\/#website\",\"url\":\"https:\/\/www.369usa.com\/blog\/\",\"name\":\"369\u7ebd\u7ea6\u7f51\u7ad9\u8bbe\u8ba1\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.369usa.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.369usa.com\/blog\/#\/schema\/person\/1c260c42af4aadda7f89a0081f6591b6\",\"name\":\"darkersss\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.369usa.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/2c538d84b753eed6f6f714becf9b3955?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/2c538d84b753eed6f6f714becf9b3955?s=96&d=mm&r=g\",\"caption\":\"darkersss\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Local HTTPS server - \u7ebd\u7ea6\u7f51\u7ad9\u8bbe\u8ba1\u535a\u5ba2","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.369usa.com\/blog\/local-https-server\/","og_locale":"en_US","og_type":"article","og_title":"Local HTTPS server - \u7ebd\u7ea6\u7f51\u7ad9\u8bbe\u8ba1\u535a\u5ba2","og_description":"const express = require('express'); const path = require('path'); const https = require('https'); const http = require('http'); const fs = require('fs'); const app = express(); const credentials = { key: fs.readFileSync('.\/.cert\/key.pem'), cert: fs.readFileSync('.\/.cert\/cert.pem') }; app.use(express.static(path.join(__dirname, 'build'))); app.get('\/', function (req, res) { res.sendFile(path.join(__dirname, 'build', 'index.html')); }); var httpServer = http.createServer(app); var httpsServer = https.createServer(credentials, app); httpServer.listen(3001); httpsServer.listen(443); &hellip; Continue reading \"Local HTTPS server\"","og_url":"https:\/\/www.369usa.com\/blog\/local-https-server\/","og_site_name":"\u7ebd\u7ea6\u7f51\u7ad9\u8bbe\u8ba1\u535a\u5ba2","article_published_time":"2021-04-23T17:12:11+00:00","author":"darkersss","twitter_card":"summary_large_image","twitter_misc":{"Written by":"darkersss"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.369usa.com\/blog\/local-https-server\/","url":"https:\/\/www.369usa.com\/blog\/local-https-server\/","name":"Local HTTPS server - \u7ebd\u7ea6\u7f51\u7ad9\u8bbe\u8ba1\u535a\u5ba2","isPartOf":{"@id":"https:\/\/www.369usa.com\/blog\/#website"},"datePublished":"2021-04-23T17:12:11+00:00","dateModified":"2021-04-23T17:12:11+00:00","author":{"@id":"https:\/\/www.369usa.com\/blog\/#\/schema\/person\/1c260c42af4aadda7f89a0081f6591b6"},"breadcrumb":{"@id":"https:\/\/www.369usa.com\/blog\/local-https-server\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.369usa.com\/blog\/local-https-server\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.369usa.com\/blog\/local-https-server\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.369usa.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Local HTTPS server"}]},{"@type":"WebSite","@id":"https:\/\/www.369usa.com\/blog\/#website","url":"https:\/\/www.369usa.com\/blog\/","name":"369\u7ebd\u7ea6\u7f51\u7ad9\u8bbe\u8ba1","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.369usa.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.369usa.com\/blog\/#\/schema\/person\/1c260c42af4aadda7f89a0081f6591b6","name":"darkersss","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.369usa.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/2c538d84b753eed6f6f714becf9b3955?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2c538d84b753eed6f6f714becf9b3955?s=96&d=mm&r=g","caption":"darkersss"}}]}},"_links":{"self":[{"href":"https:\/\/www.369usa.com\/blog\/wp-json\/wp\/v2\/posts\/249"}],"collection":[{"href":"https:\/\/www.369usa.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.369usa.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.369usa.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.369usa.com\/blog\/wp-json\/wp\/v2\/comments?post=249"}],"version-history":[{"count":1,"href":"https:\/\/www.369usa.com\/blog\/wp-json\/wp\/v2\/posts\/249\/revisions"}],"predecessor-version":[{"id":250,"href":"https:\/\/www.369usa.com\/blog\/wp-json\/wp\/v2\/posts\/249\/revisions\/250"}],"wp:attachment":[{"href":"https:\/\/www.369usa.com\/blog\/wp-json\/wp\/v2\/media?parent=249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.369usa.com\/blog\/wp-json\/wp\/v2\/categories?post=249"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.369usa.com\/blog\/wp-json\/wp\/v2\/tags?post=249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}