@pbvision/fastify-firestore-service 0.0.42 → 0.0.44
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/package.json +1 -1
- package/src/api/api.js +18 -2
package/package.json
CHANGED
package/src/api/api.js
CHANGED
|
@@ -258,9 +258,13 @@ class API {
|
|
|
258
258
|
* @private
|
|
259
259
|
*/
|
|
260
260
|
__setCORSHeaders (origin, headers) {
|
|
261
|
-
this.
|
|
261
|
+
this.constructor.setCORSHeadersOnReply(this.__reply, origin, headers)
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
static setCORSHeadersOnReply (reply, origin, headers) {
|
|
265
|
+
reply.header('Access-Control-Allow-Origin', origin)
|
|
262
266
|
if (headers && headers.length) {
|
|
263
|
-
|
|
267
|
+
reply.header('Access-Control-Allow-Headers', headers.join(', '))
|
|
264
268
|
}
|
|
265
269
|
}
|
|
266
270
|
|
|
@@ -416,6 +420,14 @@ class API {
|
|
|
416
420
|
const inputs = this.constructor.getInputsToTrackWithSentry(this.req)
|
|
417
421
|
// istanbul ignore else
|
|
418
422
|
if (inputs) {
|
|
423
|
+
const inputsSerialized = {}
|
|
424
|
+
for (const [k, v] of Object.entries(inputs)) {
|
|
425
|
+
if (typeof v === 'object') {
|
|
426
|
+
inputsSerialized[k] = JSON.stringify(v)
|
|
427
|
+
} else {
|
|
428
|
+
inputsSerialized[k] = v
|
|
429
|
+
}
|
|
430
|
+
}
|
|
419
431
|
this.setSentryContext('inputs', inputs)
|
|
420
432
|
}
|
|
421
433
|
}
|
|
@@ -807,6 +819,10 @@ class API {
|
|
|
807
819
|
// istanbul ignore next
|
|
808
820
|
console.warn('trying to get inputs to track failed', err)
|
|
809
821
|
}
|
|
822
|
+
if (this.CORS_ORIGIN) {
|
|
823
|
+
this.setCORSHeadersOnReply(
|
|
824
|
+
reply, this.getCORSOrigin(), this.CORS_HEADERS)
|
|
825
|
+
}
|
|
810
826
|
throw new InvalidInputException(req.validationError)
|
|
811
827
|
}
|
|
812
828
|
ret = await this._callAndHandleRequestDone(reply, async () => {
|