nexabase-console 1.1.2 → 1.1.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/index.js +17 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -51,19 +51,29 @@ class NexaApp {
|
|
|
51
51
|
defaultEndpoint = window.location.origin;
|
|
52
52
|
}
|
|
53
53
|
this.endpoint = config.endpoint || defaultEndpoint;
|
|
54
|
+
// Do not set default Content-Type globally to let Axios auto-detect FormData
|
|
54
55
|
this.client = axios_1.default.create({
|
|
55
|
-
baseURL: this.endpoint
|
|
56
|
-
headers: {
|
|
57
|
-
'Content-Type': 'application/json'
|
|
58
|
-
}
|
|
56
|
+
baseURL: this.endpoint
|
|
59
57
|
});
|
|
60
|
-
// Request interceptor to attach bearer token and boundary fix
|
|
58
|
+
// Request interceptor to attach bearer/x-api-key token and boundary fix
|
|
61
59
|
this.client.interceptors.request.use((req) => {
|
|
62
60
|
if (this.token) {
|
|
61
|
+
// Send both Authorization Bearer and x-api-key for full server compatibility
|
|
63
62
|
req.headers.Authorization = `Bearer ${this.token}`;
|
|
63
|
+
req.headers['x-api-key'] = this.token;
|
|
64
|
+
}
|
|
65
|
+
// If data is FormData, remove Content-Type so Axios/Browser can format multipart boundary dynamically
|
|
66
|
+
if (typeof FormData !== 'undefined' && req.data instanceof FormData) {
|
|
67
|
+
if (req.headers) {
|
|
68
|
+
delete req.headers['Content-Type'];
|
|
69
|
+
delete req.headers['content-type'];
|
|
70
|
+
}
|
|
64
71
|
}
|
|
65
|
-
|
|
66
|
-
|
|
72
|
+
else {
|
|
73
|
+
// Otherwise default to application/json for non-FormData payload requests
|
|
74
|
+
if (req.data && req.headers && !req.headers['Content-Type'] && !req.headers['content-type']) {
|
|
75
|
+
req.headers['Content-Type'] = 'application/json';
|
|
76
|
+
}
|
|
67
77
|
}
|
|
68
78
|
return req;
|
|
69
79
|
});
|
package/package.json
CHANGED