Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

added start:dev script to use staging API URL

Blue Mousea4bc94cd66c4
diff --git a/.env.example b/.env.example
index 96b340cf9..8602e98d6 100644
--- a/.env.example
+++ b/.env.example
@@ -1,6 +1,9 @@
REACT_APP_API_URL=https://api.swetrix.com/
+REACT_APP_API_STAGING_URL=http://localhost:5005/
+
REACT_APP_CDN_URL=https://cdn.swetrix.com/
REACT_APP_BLOG_URL=https://blog.swetrix.com/
REACT_APP_AIAPI_URL=https://aiapi.swetrix.com/
+
CHOKIDAR_USEPOLLING=true
GENERATE_SOURCEMAP=false
diff --git a/package.json b/package.json
index a9b9e7058..d6e4dbd05 100644
--- a/package.json
+++ b/package.json
@@ -53,6 +53,7 @@
},
"scripts": {
"start": "react-scripts start",
+ "start:dev": "cross-env REACT_APP_RUNNING_DEV_SCRIPT=true react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --transformIgnorePatterns \"node_modules/(?!axios)/\"",
"test:ci": "CI=true npm run test",
diff --git a/src/api/index.ts b/src/api/index.ts
index 917bec8de..93b2877f1 100644
--- a/src/api/index.ts
+++ b/src/api/index.ts
@@ -20,8 +20,13 @@ import { ISharedProject } from 'redux/models/ISharedProject'
import { ISubscribers } from 'redux/models/ISubscribers'
const debug = Debug('swetrix:api')
+
+const envApiURL = process.env.REACT_APP_RUNNING_DEV_SCRIPT === 'true'
+ ? process.env.REACT_APP_API_STAGING_URL
+ : process.env.REACT_APP_API_URL
+
// @ts-ignore
-const baseURL: string = isSelfhosted ? window.env.API_URL : process.env.REACT_APP_API_URL
+const baseURL: string = isSelfhosted ? window.env.API_URL : envApiURL
const api = axios.create({
baseURL,