@niledatabase/server 4.0.0-alpha.20 → 4.0.0-alpha.21

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/index.js CHANGED
@@ -97,13 +97,18 @@ async function request(url, _init, config) {
97
97
  }
98
98
  updatedHeaders.set("host", requestUrl.host);
99
99
  if (config.api.callbackUrl) {
100
- updatedHeaders.set(X_NILE_ORIGIN, config.api.callbackUrl);
100
+ const cbUrl = new URL(config.api.callbackUrl);
101
+ debug(
102
+ `Obtained origin from config.api.callbackUrl ${config.api.callbackUrl}`
103
+ );
104
+ updatedHeaders.set(X_NILE_ORIGIN, cbUrl.origin);
101
105
  } else if (config.api.origin) {
106
+ debug(`Obtained origin from config.api.origin ${config.api.origin}`);
102
107
  updatedHeaders.set(X_NILE_ORIGIN, config.api.origin);
103
108
  } else {
104
109
  updatedHeaders.set(X_NILE_ORIGIN, requestUrl.origin);
110
+ debug(`Obtained origin from request ${requestUrl.origin}`);
105
111
  }
106
- debug(`Using origin ${updatedHeaders.get(X_NILE_ORIGIN)}`);
107
112
  const params = { ...init, headers: updatedHeaders };
108
113
  if (params.method === "POST" || params.method === "PUT") {
109
114
  try {