@navservice/core 1.75.0 → 1.77.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/es/index.js CHANGED
@@ -169,16 +169,16 @@ const _api_api = class _api {
169
169
  static resolve_base_url() {
170
170
  try {
171
171
  if ("undefined" == typeof window) throw new Error("resolveApiBaseURL must run in browser");
172
- const { hostname } = window.location;
172
+ const { origin, hostname } = window.location;
173
+ if (hostname.includes("navsoftware")) {
174
+ const apiOrigin = origin.replace(/^https?:\/\/app/, (match)=>match.replace("app", "api"));
175
+ return apiOrigin;
176
+ }
173
177
  const apiOverride = utils_environment.get;
174
178
  if ("SANDBOX" === apiOverride) return "https://api-sandbox.navsoftware.com.br";
175
179
  if ("PRODUCAO" === apiOverride) return "https://api.navsoftware.com.br";
176
180
  if ("LOCALHOST" === apiOverride) return "http://localhost:8787";
177
181
  if ("localhost" === hostname || hostname.startsWith("localhost")) return "http://localhost:8787";
178
- const isNavSoftware = hostname.includes("navsoftware");
179
- const isSandbox = hostname.includes("sandbox");
180
- if (isNavSoftware && isSandbox) return "https://api-sandbox.navsoftware.com.br";
181
- if (isNavSoftware) return "https://api.navsoftware.com.br";
182
182
  } catch (error) {
183
183
  throw new Error(`Ambiente não reconhecido: ${error}`);
184
184
  }
@@ -256,7 +256,11 @@ const _api_api = class _api {
256
256
  if (typeof window === "undefined") {
257
257
  throw new Error("resolveApiBaseURL must run in browser");
258
258
  }
259
- const { hostname } = window.location;
259
+ const { origin, hostname } = window.location;
260
+ if (hostname.includes("navsoftware")) {
261
+ const apiOrigin = origin.replace(/^https?:\/\/app/, (match)=>match.replace("app", "api"));
262
+ return apiOrigin;
263
+ }
260
264
  const apiOverride = utils_environment.get;
261
265
  if (apiOverride === "SANDBOX") {
262
266
  return "https://api-sandbox.navsoftware.com.br";
@@ -270,14 +274,6 @@ const _api_api = class _api {
270
274
  if (hostname === "localhost" || hostname.startsWith("localhost")) {
271
275
  return "http://localhost:8787";
272
276
  }
273
- const isNavSoftware = hostname.includes("navsoftware");
274
- const isSandbox = hostname.includes("sandbox");
275
- if (isNavSoftware && isSandbox) {
276
- return "https://api-sandbox.navsoftware.com.br";
277
- }
278
- if (isNavSoftware) {
279
- return "https://api.navsoftware.com.br";
280
- }
281
277
  } catch (error) {
282
278
  throw new Error(`Ambiente não reconhecido: ${error}`);
283
279
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navservice/core",
3
- "version": "1.75.0",
3
+ "version": "1.77.0",
4
4
  "description": "Service core de todos os micro serviços",
5
5
  "type": "module",
6
6
  "exports": {