File tree Expand file tree Collapse file tree
packages/server/api/src/app Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,7 +4,10 @@ import {
44} from '@fastify/type-provider-typebox' ;
55import { AppSystemProp , logger , system } from '@openops/server-shared' ;
66import { ALL_PRINCIPAL_TYPES , OpenOpsId } from '@openops/shared' ;
7- import { allowAllOriginsHookHandler } from '../helper/allow-all-origins-hook-handler' ;
7+ import {
8+ allowAllOriginsHookHandler ,
9+ registerOptionsEndpoint ,
10+ } from '../helper/allow-all-origins-hook-handler' ;
811import { getVerifiedUser } from '../user-info/cloud-auth' ;
912import { flowTemplateService } from './flow-template.service' ;
1013
@@ -26,18 +29,7 @@ export const cloudTemplateController: FastifyPluginAsyncTypebox = async (
2629 // cloud templates are available on any origin
2730 app . addHook ( 'onRequest' , allowAllOriginsHookHandler ) ;
2831
29- app . options (
30- '*' ,
31- {
32- config : {
33- allowedPrincipals : ALL_PRINCIPAL_TYPES ,
34- skipAuth : true ,
35- } ,
36- } ,
37- ( _request , reply ) => {
38- return reply . status ( 204 ) . send ( ) ;
39- } ,
40- ) ;
32+ registerOptionsEndpoint ( app ) ;
4133
4234 app . get (
4335 '/' ,
Original file line number Diff line number Diff line change 1- import { onRequestHookHandler } from 'fastify' ;
1+ import { ALL_PRINCIPAL_TYPES } from '@openops/shared' ;
2+ import { FastifyInstance , onRequestHookHandler } from 'fastify' ;
23
34export const allowAllOriginsHookHandler : onRequestHookHandler = (
45 request ,
@@ -21,3 +22,18 @@ export const allowAllOriginsHookHandler: onRequestHookHandler = (
2122
2223 done ( ) ;
2324} ;
25+
26+ export function registerOptionsEndpoint ( app : FastifyInstance ) {
27+ app . options (
28+ '*' ,
29+ {
30+ config : {
31+ allowedPrincipals : ALL_PRINCIPAL_TYPES ,
32+ skipAuth : true ,
33+ } ,
34+ } ,
35+ ( _request , reply ) => {
36+ return reply . status ( 204 ) . send ( ) ;
37+ } ,
38+ ) ;
39+ }
Original file line number Diff line number Diff line change 11import { FastifyPluginAsyncTypebox } from '@fastify/type-provider-typebox' ;
22import { AppSystemProp , logger , system } from '@openops/server-shared' ;
33import { ALL_PRINCIPAL_TYPES } from '@openops/shared' ;
4- import { allowAllOriginsHookHandler } from '../helper/allow-all-origins-hook-handler' ;
4+ import {
5+ allowAllOriginsHookHandler ,
6+ registerOptionsEndpoint ,
7+ } from '../helper/allow-all-origins-hook-handler' ;
58import { getVerifiedUser } from './cloud-auth' ;
69
710export const userInfoModule : FastifyPluginAsyncTypebox = async ( app ) => {
@@ -23,19 +26,7 @@ export const userInfoController: FastifyPluginAsyncTypebox = async (app) => {
2326
2427 // user-info is available on any origin
2528 app . addHook ( 'onRequest' , allowAllOriginsHookHandler ) ;
26-
27- app . options (
28- '*' ,
29- {
30- config : {
31- allowedPrincipals : ALL_PRINCIPAL_TYPES ,
32- skipAuth : true ,
33- } ,
34- } ,
35- ( _request , reply ) => {
36- return reply . status ( 204 ) . send ( ) ;
37- } ,
38- ) ;
29+ registerOptionsEndpoint ( app ) ;
3930
4031 app . get (
4132 '/' ,
You can’t perform that action at this time.
0 commit comments