This repository was archived by the owner on Aug 5, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +34
-15
lines changed Expand file tree Collapse file tree 3 files changed +34
-15
lines changed Original file line number Diff line number Diff line change @@ -10,13 +10,7 @@ The gateway can be run locally (no cloud dependencies), in GitHub CodeSpaces or
10
10
| :exclamation : This implementation is for prototyping only and not meant for production. |
11
11
| --------------------------------------------------------------------------------------- |
12
12
13
- ## Local development / GitHub Codespaces
14
-
15
- Running the gateway in GitHub codespaces will give you an addressable web server that will be reachable by devices which the codespace
16
- is active. It is an easy to get a development gateway available on the web without having to deal with network issues.
17
- The tools will automatically detect CodeSpaces and self configure.
18
-
19
- Make sure to follow the provisioning steps in the documentation before trying to run locally.
13
+ ## Local development
20
14
21
15
- setup Node.JS 18
22
16
@@ -54,6 +48,12 @@ You can also access the Swagger sandbox locally:
54
48
- Click Authorize
55
49
- Use user/password ` devstoreaccount1:Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw== `
56
50
51
+ ### GitHub CodeSpaces, CodeSandbox.io
52
+
53
+ Running the gateway in GitHub Codespaces/CodeSandbox will give you an addressable web server that will be reachable by devices which the codespace
54
+ is active. It is an easy to get a development gateway available on the web without having to deal with network issues.
55
+ The tools will automatically detect CodeSpaces/CodeSandbox and self configure.
56
+
57
57
## Azure services
58
58
59
59
Make sure to follow the provisioning steps in the documentation before trying to run locally.
Original file line number Diff line number Diff line change @@ -8,14 +8,28 @@ const out = dotenv.config({ path: azure ? "./.env" : "./local.env" })
8
8
if ( out . error ) throw out . error
9
9
10
10
const port = process . env . PORT || ( process . env . PORT = "7071" )
11
- // codespace special handling
12
- const { CODESPACE_NAME , GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN } = process . env
11
+ const {
12
+ CODESPACE_NAME ,
13
+ GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN ,
14
+ CODESANDBOX_HOST ,
15
+ } = process . env
16
+ // GitHub codespaces
13
17
if ( CODESPACE_NAME && GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN ) {
14
18
process . env . WEBSITE_HOSTNAME = `${ CODESPACE_NAME } -${ port } .${ GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN } `
15
19
process . env . WEBSITE_PROTOCOL = "https"
16
- console . log ( `GitHub Codespace environment detected...` )
17
- console . warn ( `- make sure to change the visibility of port '${ port } ' to 'Public'` )
18
- } else if ( ! azure ) {
20
+ console . log ( `GitHub Codespace detected...` )
21
+ console . warn (
22
+ `- make sure to change the visibility of port '${ port } ' to 'Public'`
23
+ )
24
+ }
25
+ // Codesandbox
26
+ else if ( CODESANDBOX_HOST ) {
27
+ process . env . WEBSITE_HOSTNAME = CODESANDBOX_HOST
28
+ process . env . WEBSITE_PROTOCOL = "https"
29
+ console . log ( `Codesandbox.io detected...` )
30
+ }
31
+ // local dev
32
+ else if ( ! azure ) {
19
33
const address = ( ( ) => {
20
34
const nis = networkInterfaces ( )
21
35
for ( const interfaceName in nis ) {
Original file line number Diff line number Diff line change @@ -6,10 +6,15 @@ import { DeviceInfo } from "./schema"
6
6
*/
7
7
export function selfUrl ( ) {
8
8
// use https://learn.microsoft.com/en-us/azure/app-service/reference-app-settings?tabs=kudu%2Cdotnet
9
- const hostname = process . env [ " WEBSITE_HOSTNAME" ]
9
+ const hostname = process . env . WEBSITE_HOSTNAME
10
10
if ( ! hostname ) throw new Error ( "WEBSITE_HOSTNAME not configured" )
11
- const protocol = / ^ ( 1 2 7 \. | 0 \. | l o c a l h o s t ) / i. test ( hostname ) ? "http" : "https"
12
- return `${ protocol } ://${ hostname } `
11
+ const protocol =
12
+ process . env . WEBSITE_PROTOCOL || / ^ ( 1 2 7 \. | 0 \. | l o c a l h o s t ) / i. test ( hostname )
13
+ ? "http"
14
+ : "https"
15
+ const url = `${ protocol } ://${ hostname } `
16
+ console . log ( { url } )
17
+ return url
13
18
}
14
19
15
20
export function selfHost ( ) {
You can’t perform that action at this time.
0 commit comments