chore: Don't break when Appsmtih API URL isn't set (#37309)
We actually don't need the `APPSMITH_API_BASE_URL` variable to be varying in production ever at all, and the `routes.ts` file already does have a default for this (on EE). Let's just use that instead of throwing an impact-less error. Ideally though, we shouldn't have this env variable at all. Less things that are configurable, less things that can break other things. ## Automation /test sanity ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/11812221529> > Commit: f049d468998530cddd9f7ad45542790c9e12241b > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11812221529&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Sanity` > Spec: > <hr>Wed, 13 Nov 2024 07:41:57 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes - **New Features** - Introduced constants for API URLs to streamline endpoint configurations. - **Bug Fixes** - Updated API request URLs to use new constants, ensuring consistency across the application. - **Refactor** - Centralized route constants to improve maintainability. - Renamed entities in test cases for clarity while preserving functionality. - **Chores** - Removed obsolete environment variable related to API base URL from the Docker configuration. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
parent
a601acf173
commit
77bae7c0c6
9
app/client/packages/rts/src/constants/routes.ts
Normal file
9
app/client/packages/rts/src/constants/routes.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
const BASE_API_URL = "http://localhost:8091";
|
||||
|
||||
export const RTS_BASE_PATH = "/rts";
|
||||
export const RTS_BASE_API_PATH = "/rts-api/v1";
|
||||
export const RTS_BASE_API_URL = `${BASE_API_URL}${RTS_BASE_API_PATH}`;
|
||||
|
||||
export const BASE_APPSMITH_API_URL =
|
||||
process.env.APPSMITH_API_BASE_URL || "http://localhost:8080/api/v1";
|
||||
export const INTERNAL_BASE_URL = "http://localhost:8080/internal/v1";
|
||||
|
|
@ -2,7 +2,7 @@ import type { Socket } from "socket.io";
|
|||
import log from "loglevel";
|
||||
import axios from "axios";
|
||||
|
||||
const API_BASE_URL = process.env.APPSMITH_API_BASE_URL;
|
||||
import { BASE_APPSMITH_API_URL } from "@constants/routes";
|
||||
|
||||
export async function tryAuth(socket: Socket) {
|
||||
/* ********************************************************* */
|
||||
|
|
@ -35,7 +35,7 @@ export async function tryAuth(socket: Socket) {
|
|||
try {
|
||||
response = await axios.request({
|
||||
method: "GET",
|
||||
url: API_BASE_URL + "/users/me",
|
||||
url: BASE_APPSMITH_API_URL + "/users/me",
|
||||
headers: {
|
||||
Cookie: sessionCookie,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -12,9 +12,7 @@ import ast_routes from "./routes/ast_routes";
|
|||
import dsl_routes from "./routes/dsl_routes";
|
||||
import health_check_routes from "./routes/health_check_routes";
|
||||
|
||||
const RTS_BASE_PATH = "/rts";
|
||||
|
||||
export const RTS_BASE_API_PATH = "/rts-api/v1";
|
||||
import { RTS_BASE_PATH, RTS_BASE_API_PATH } from "@constants/routes";
|
||||
|
||||
// Setting the logLevel for all log messages
|
||||
const logLevel: LogLevelDesc = (process.env.APPSMITH_LOG_LEVEL ||
|
||||
|
|
@ -22,13 +20,6 @@ const logLevel: LogLevelDesc = (process.env.APPSMITH_LOG_LEVEL ||
|
|||
|
||||
log.setLevel(logLevel);
|
||||
|
||||
const API_BASE_URL = process.env.APPSMITH_API_BASE_URL;
|
||||
|
||||
if (API_BASE_URL == null || API_BASE_URL === "") {
|
||||
log.error("Please provide a valid value for `APPSMITH_API_BASE_URL`.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const APPSMITH_RTS_PORT = process.env.APPSMITH_RTS_PORT || 8091;
|
||||
|
||||
//Disable x-powered-by header to prevent information disclosure
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import app, { RTS_BASE_API_PATH } from "../server";
|
||||
import app from "../server";
|
||||
import { RTS_BASE_API_PATH } from "@constants/routes";
|
||||
import supertest from "supertest";
|
||||
|
||||
const singleScript = {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,6 @@ APPSMITH_DB_URL=mongodb://$MONGO_USER:$DB_PASSWORD@localhost:27017/appsmith
|
|||
APPSMITH_POSTGRES_DB_URL=postgresql://appsmith:$DB_PASSWORD@localhost:5432/appsmith
|
||||
APPSMITH_MONGODB_USER=$MONGO_USER
|
||||
APPSMITH_MONGODB_PASSWORD=$DB_PASSWORD
|
||||
APPSMITH_API_BASE_URL=http://localhost:8080/api/v1
|
||||
|
||||
APPSMITH_REDIS_URL=redis://127.0.0.1:6379
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user