Skip to content

Commit

Permalink
fix(developer): dry cors
Browse files Browse the repository at this point in the history
  • Loading branch information
steveoh committed May 8, 2024
1 parent ce0717c commit a5cdd54
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/developer/functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { safelyInitializeApp } from './firebase.js';

safelyInitializeApp();

const cors = [/ut-dts-agrc-web-api-dev-self-service\.web\.app$/, /api\.mapserv\.utah\.gov$/];

/**
* @template CallableRequestT
* @typedef {import('firebase-functions/v2/https').CallableRequest<CallableRequestT>} CallableRequest
Expand Down Expand Up @@ -34,7 +36,7 @@ export const onCreateUser = auth.user().onCreate(async (user) => {
* @returns {Promise<string>} The api key string value.
*/
export const createKey = https.onCall(
{ cors: [/ut-dts-agrc-web-api-dev-self-service\.web\.app$/] },
{ cors },
async (request) => {
if (request.auth === undefined) {
debug('[https::createKey] no auth context');
Expand Down Expand Up @@ -64,7 +66,7 @@ export const createKey = https.onCall(
* }[]>} an array of minimal key objects
*/
export const keys = https.onCall(
{ cors: [/ut-dts-agrc-web-api-dev-self-service\.web\.app$/] },
{ cors },
async (request) => {
debug('[https::keys] starting');

Expand Down Expand Up @@ -92,7 +94,7 @@ export const keys = https.onCall(
*/
export const validateClaim = https.onCall(
{
cors: [/ut-dts-agrc-web-api-dev-self-service\.web\.app$/],
cors,
secrets: ['LEGACY_PEPPER'],
},
async (request) => {
Expand Down

0 comments on commit a5cdd54

Please sign in to comment.