From 42ca70f80f03f80e7eab0621311e5cf039da09a0 Mon Sep 17 00:00:00 2001 From: Rodrigo Gomez Palacio Date: Tue, 6 Feb 2024 14:20:58 -0600 Subject: [PATCH 1/2] Change API port number for use in dev-dev environments Motivation: the API dev environment uses 3000, not 3001 --- src/shared/managers/SdkEnvironment.ts | 6 +++--- test/unit/modules/sdkEnvironment.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/shared/managers/SdkEnvironment.ts b/src/shared/managers/SdkEnvironment.ts index 28a767e39..56465b635 100644 --- a/src/shared/managers/SdkEnvironment.ts +++ b/src/shared/managers/SdkEnvironment.ts @@ -8,7 +8,7 @@ import Environment from '../helpers/Environment'; const RESOURCE_HTTP_PORT = 4000; const RESOURCE_HTTPS_PORT = 4001; -const API_URL_PORT = 3001; +const API_URL_PORT = 3000; const TURBINE_API_URL_PORT = 18080; const TURBINE_ENDPOINTS = ['outcomes', 'on_focus']; @@ -128,9 +128,9 @@ export default class SdkEnvironment { switch (buildEnv) { case EnvironmentKind.Development: if (SdkEnvironment.isTurbineEndpoint(action)) { - return new URL(`https://${apiOrigin}:${TURBINE_API_URL_PORT}/api/v1`); + return new URL(`http://${apiOrigin}:${TURBINE_API_URL_PORT}/api/v1`); } - return new URL(`https://${apiOrigin}:${API_URL_PORT}/api/v1`); + return new URL(`http://${apiOrigin}:${API_URL_PORT}/api/v1`); case EnvironmentKind.Staging: return new URL(`https://${apiOrigin}/api/v1`); case EnvironmentKind.Production: diff --git a/test/unit/modules/sdkEnvironment.ts b/test/unit/modules/sdkEnvironment.ts index cb137025e..744cb8abc 100644 --- a/test/unit/modules/sdkEnvironment.ts +++ b/test/unit/modules/sdkEnvironment.ts @@ -27,7 +27,7 @@ test('getWindowEnv should get host window environment', async (t) => { test('API URL should be valid for development environment', async (t) => { t.is( SdkEnvironment.getOneSignalApiUrl(EnvironmentKind.Development).toString(), - 'https://localhost:3001/api/v1', + 'https://localhost:3000/api/v1', ); }); From 23b9f876ea37ef147aacbb55beaf41335abbee03 Mon Sep 17 00:00:00 2001 From: Rodrigo Gomez Palacio Date: Tue, 6 Feb 2024 14:27:00 -0600 Subject: [PATCH 2/2] Update build script to use localhost as API origin in dev-dev envs Motivation: we default to onesignal.com if no API origin is passed in. Thus, we should specify that the api origin should be localhost for dev-dev --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index da0248251..64bff7df6 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "build:prod": "ENV=production yarn transpile:sources && ENV=production yarn bundle-sw && ENV=production yarn bundle-sdk && ENV=production yarn bundle-page-sdk-es6 && bundlesize && ENV=production build/scripts/publish.sh", "test": "NODE_OPTIONS=\"--trace-warnings --unhandled-rejections=warn\" yarn run jest --detectOpenHandles --forceExit --runInBand", "publish": "yarn clean && yarn build:prod && yarn", - "build:dev-dev": "./build/scripts/build.sh -f development -t development", + "build:dev-dev": "./build/scripts/build.sh -f development -t development -a localhost", "build:dev-prod": "./build/scripts/build.sh -f development -t production", "build:dev-stag": "./build/scripts/build.sh -f development -t staging", "lint": "eslint src --ext .js,.jsx,.ts,.tsx; yarn prettylint 'src/**/*' 'test/**/*' '__test__/**/*' --no-editorconfig",