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,6 +29,8 @@ export const cloudTemplateController: FastifyPluginAsyncTypebox = async (
2629 // cloud templates are available on any origin
2730 app . addHook ( 'onRequest' , allowAllOriginsHookHandler ) ;
2831
32+ registerOptionsEndpoint ( app ) ;
33+
2934 app . get (
3035 '/' ,
3136 {
Original file line number Diff line number Diff line change 1- import { onRequestHookHandler } from 'fastify/types/hooks' ;
1+ import { ALL_PRINCIPAL_TYPES } from '@openops/shared' ;
2+ import { FastifyInstance , onRequestHookHandler } from 'fastify' ;
23
34export const allowAllOriginsHookHandler : onRequestHookHandler = (
45 request ,
@@ -19,9 +20,20 @@ export const allowAllOriginsHookHandler: onRequestHookHandler = (
1920
2021 void reply . header ( 'Access-Control-Allow-Credentials' , 'true' ) ;
2122
22- if ( request . method === 'OPTIONS' ) {
23- return void reply . status ( 204 ) . send ( ) ;
24- }
25-
2623 done ( ) ;
2724} ;
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,6 +26,7 @@ export const userInfoController: FastifyPluginAsyncTypebox = async (app) => {
2326
2427 // user-info is available on any origin
2528 app . addHook ( 'onRequest' , allowAllOriginsHookHandler ) ;
29+ registerOptionsEndpoint ( app ) ;
2630
2731 app . get (
2832 '/' ,
You can’t perform that action at this time.
0 commit comments