@vtecx/vtecxnext 2.2.10 → 2.2.11

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.
@@ -81,7 +81,7 @@ export declare class VtecxNext {
81
81
  null2blank: (val: string | undefined | null) => string;
82
82
  /**
83
83
  * X-Requested-With header check.
84
- * If not specified, set status 417 to the response.
84
+ * If not specified, set status 401 to the response.
85
85
  * @return Response if no X-Requested-With header is specified
86
86
  */
87
87
  checkXRequestedWith: () => Response | undefined;
package/dist/vtecxnext.js CHANGED
@@ -143,7 +143,7 @@ class VtecxNext {
143
143
  };
144
144
  /**
145
145
  * X-Requested-With header check.
146
- * If not specified, set status 417 to the response.
146
+ * If not specified, set status 401 to the response.
147
147
  * @return Response if no X-Requested-With header is specified
148
148
  */
149
149
  checkXRequestedWith = () => {
@@ -155,9 +155,9 @@ class VtecxNext {
155
155
  this.req.headers.forEach((value, key, parent) => {
156
156
  //console.log(`[vtecxnext checkXRequestedWith] key=${key} value=${value}`)
157
157
  if (!hasX) {
158
- if ((key.startsWith('x-') || key.startsWith('X-')) &&
159
- key.indexOf('invoke') === -1 &&
160
- value !== undefined && value !== '') {
158
+ const keyLower = key.toLocaleLowerCase();
159
+ if ((keyLower.startsWith('x-') && !keyLower.startsWith('x-forwarded')) ||
160
+ keyLower === 'authorization') {
161
161
  //console.log(`[vtecxnext checkXRequestedWith] key=${key} value=${value}`)
162
162
  hasX = true;
163
163
  }
@@ -166,7 +166,7 @@ class VtecxNext {
166
166
  //console.log(`[vtecxnext checkXRequestedWith] end.`)
167
167
  if (!hasX) {
168
168
  return new Response('', {
169
- status: 417
169
+ status: 401
170
170
  });
171
171
  }
172
172
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtecx/vtecxnext",
3
- "version": "2.2.10",
3
+ "version": "2.2.11",
4
4
  "description": "vte.cx Next.js api",
5
5
  "main": "dist/index.js",
6
6
  "files": [