@merkaly/nuxt 0.7.1 → 0.7.3

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/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.14.0"
6
6
  },
7
- "version": "0.7.1",
7
+ "version": "0.7.3",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
@@ -81,8 +81,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
81
81
  }>, {
82
82
  mode: PlaceTypes;
83
83
  disabled: boolean;
84
- countries: string[];
85
84
  placeholder: string;
85
+ countries: string[];
86
86
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
87
87
  declare const _default: typeof __VLS_export;
88
88
  export default _default;
@@ -81,8 +81,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
81
81
  }>, {
82
82
  mode: PlaceTypes;
83
83
  disabled: boolean;
84
- countries: string[];
85
84
  placeholder: string;
85
+ countries: string[];
86
86
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
87
87
  declare const _default: typeof __VLS_export;
88
88
  export default _default;
@@ -41,6 +41,7 @@ export interface ParamsOptions {
41
41
  headers?: FetchOptions['headers'];
42
42
  method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
43
43
  query?: FetchOptions['query'];
44
+ requiresTenant?: boolean;
44
45
  timeout?: FetchOptions['timeout'];
45
46
  }
46
47
  export type ApiOptions<TData = unknown, TMeta = Record<string, unknown>, TParams = object> = ParamsOptions & HooksOptions<TData, TMeta, TParams> & RefOptions & {
@@ -5,7 +5,8 @@ export default defineNuxtPlugin(({ provide }) => provide("api", async (url, opti
5
5
  const { token } = useAuth();
6
6
  const { tenant } = useTenant();
7
7
  const { public: { merkaly } } = useRuntimeConfig();
8
- if (!tenant.value && !options.global && merkaly.auth0.requiresTenant) {
8
+ const requiresTenant = options.requiresTenant ?? merkaly.auth0.requiresTenant;
9
+ if (!tenant.value && !options.global && requiresTenant) {
9
10
  throw new Error(
10
11
  `[api] Tenant context is required but not set for: ${url}
11
12
  This surface has requiresTenant: true. Possible causes:
@@ -1,6 +1,7 @@
1
1
  import { defineEventHandler, getRequestURL, proxyRequest } from "h3";
2
2
  import { useRuntimeConfig } from "#imports";
3
3
  const GLOBAL_API_HEADER = "x-merkaly-global";
4
+ const TENANT_HOST_HEADER = "x-merkaly-host";
4
5
  const API_PREFIX_PATTERN = /^\/api\/?/;
5
6
  const API_ROUTE_PATTERN = /^\/api(?:\/|$)/;
6
7
  const EDGE_SLASH_PATTERN = /^\/|\/$/g;
@@ -27,6 +28,7 @@ export default defineEventHandler((event) => {
27
28
  const prefix = isGlobalRequest(event.node.req.headers[GLOBAL_API_HEADER]) ? "" : $config.merkaly.api.prefix;
28
29
  const path = resolveProxyPath(prefix, url.pathname, url.search);
29
30
  event.node.req.headers["x-forwarded-host"] = url.host;
31
+ event.node.req.headers[TENANT_HOST_HEADER] = url.host;
30
32
  if (import.meta.dev && targetOrigin.hostname.endsWith(".test")) {
31
33
  process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
32
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@merkaly/nuxt",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/merkaly-io/nuxt.git"