@pbvision/fastify-firestore-service 0.0.42 → 0.0.43

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/api/api.js +10 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pbvision/fastify-firestore-service",
3
- "version": "0.0.42",
3
+ "version": "0.0.43",
4
4
  "description": "Web Framework using Fastify and Firestore ORM",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
package/src/api/api.js CHANGED
@@ -258,9 +258,13 @@ class API {
258
258
  * @private
259
259
  */
260
260
  __setCORSHeaders (origin, headers) {
261
- this.__reply.header('Access-Control-Allow-Origin', origin)
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
- this.__reply.header('Access-Control-Allow-Headers', headers.join(', '))
267
+ reply.header('Access-Control-Allow-Headers', headers.join(', '))
264
268
  }
265
269
  }
266
270
 
@@ -807,6 +811,10 @@ class API {
807
811
  // istanbul ignore next
808
812
  console.warn('trying to get inputs to track failed', err)
809
813
  }
814
+ if (this.CORS_ORIGIN) {
815
+ this.setCORSHeadersOnReply(
816
+ reply, this.getCORSOrigin(), this.CORS_HEADERS)
817
+ }
810
818
  throw new InvalidInputException(req.validationError)
811
819
  }
812
820
  ret = await this._callAndHandleRequestDone(reply, async () => {