Skip to content

Commit 75ca70f

Browse files
committed
Test
1 parent cb38688 commit 75ca70f

3 files changed

Lines changed: 39 additions & 12 deletions

File tree

packages/server/api/src/app/app.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ export const setupApp = async (
139139

140140
await app.register(cors, {
141141
origin: (origin, callback) => {
142+
logger.info('Allow cors request plugin');
143+
142144
if (origin === system.get(SharedSystemProp.FRONTEND_URL)) {
143145
return callback(null, true);
144146
}

packages/server/api/src/app/flow-template/cloud-template.controller.ts

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,43 @@ import { flowTemplateService } from './flow-template.service';
1111
export 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
{

packages/server/api/src/app/helper/allow-all-origins-hook-handler.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
import { logger } from '@openops/server-shared';
12
import { onRequestHookHandler } from 'fastify/types/hooks';
23

34
export const allowAllOriginsHookHandler: onRequestHookHandler = (
45
request,
56
reply,
67
done,
78
) => {
9+
logger.info('Allow cors request');
10+
811
void reply.header(
912
'Access-Control-Allow-Origin',
1013
request.headers.origin || request.headers['Ops-Origin'] || '*',
@@ -17,7 +20,7 @@ export const allowAllOriginsHookHandler: onRequestHookHandler = (
1720
'Content-Type,Ops-Origin,Authorization',
1821
);
1922

20-
void reply.header('Access-Control-Allow-Credentials', 'true');
23+
void reply.header('Access-Control-Allow-Credentials', 'false');
2124

2225
if (request.method === 'OPTIONS') {
2326
return void reply.status(204).send();

0 commit comments

Comments
 (0)