@@ -11,21 +11,43 @@ import { flowTemplateService } from './flow-template.service';
1111export const cloudTemplateController : FastifyPluginAsyncTypebox = async (
1212 app ,
1313) => {
14- const publicKey = system . get ( AppSystemProp . FRONTEGG_PUBLIC_KEY ) ;
15- const connectionPageEnabled = system . getBoolean (
16- AppSystemProp . CLOUD_CONNECTION_PAGE_ENABLED ,
17- ) ;
18-
19- if ( ! publicKey || ! connectionPageEnabled ) {
20- logger . info (
21- 'Missing Frontegg configuration, disabling cloud templates API' ,
22- ) ;
23- return ;
24- }
14+ const publicKey = system . get ( AppSystemProp . FRONTEGG_PUBLIC_KEY ) || '' ;
15+ // const connectionPageEnabled = system.getBoolean(
16+ // AppSystemProp.CLOUD_CONNECTION_PAGE_ENABLED,
17+ // );
18+ //
19+ // if (!publicKey || !connectionPageEnabled) {
20+ // logger.info(
21+ // 'Missing Frontegg configuration, disabling cloud templates API',
22+ // );
23+ // return;
24+ // }
2525
2626 // cloud templates are available on any origin
2727 app . addHook ( 'onRequest' , allowAllOriginsHookHandler ) ;
2828
29+ app . options ( '/*' , async ( request , reply ) => {
30+ logger . info ( 'Options request' ) ;
31+
32+ void reply . header (
33+ 'Access-Control-Allow-Origin' ,
34+ request . headers . origin || request . headers [ 'Ops-Origin' ] || '*' ,
35+ ) ;
36+
37+ void reply . header ( 'Access-Control-Allow-Methods' , 'GET,OPTIONS' ) ;
38+
39+ void reply . header (
40+ 'Access-Control-Allow-Headers' ,
41+ 'Content-Type,Ops-Origin,Authorization' ,
42+ ) ;
43+
44+ void reply . header ( 'Access-Control-Allow-Credentials' , 'false' ) ;
45+
46+ if ( request . method === 'OPTIONS' ) {
47+ return void reply . status ( 204 ) . send ( ) ;
48+ }
49+ } ) ;
50+
2951 app . get (
3052 '/' ,
3153 {
0 commit comments