MCPcopy Create free account
hub / github.com/Azure-Samples/todo-csharp-cosmos-sql / getBaseURL

Function getBaseURL

tests/playwright.config.ts:51–80  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49};
50
51function getBaseURL() {
52 // If we don't have URL and aren't in CI, then try to load from environment
53 if (!process.env.REACT_APP_WEB_BASE_URL && !process.env.CI) {
54 // Try to get env in .azure folder
55 let environment = process.env.AZURE_ENV_NAME;
56 if (!environment) {
57 // Couldn't find env name in env var, let's try to load from .azure folder
58 try {
59 let configfilePath = join(__dirname, "..", ".azure", "config.json");
60 if (fs.existsSync(configfilePath)) {
61 let configFile = JSON.parse(fs.readFileSync(configfilePath, "utf-8"));
62 environment = configFile["defaultEnvironment"];
63 }
64 } catch (err) {
65 console.log("Unable to load default environment: " + err);
66 }
67 }
68
69 if (environment) {
70 let envPath = join(__dirname, "..", ".azure", environment, ".env");
71 console.log("Loading env from: " + envPath);
72 dotenv.config({ path: envPath });
73 return process.env.REACT_APP_WEB_BASE_URL;
74 }
75 }
76
77 let baseURL = process.env.REACT_APP_WEB_BASE_URL || "http://localhost:3000";
78 console.log("baseUrl: " + baseURL);
79 return baseURL;
80}
81
82export default config;

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected