Skip to content

Commit b8a8ae0

Browse files
committed
Cache CORS responses, to half the requests involved in basically everything
1 parent c7f556b commit b8a8ae0

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/httptoolkit-server.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,10 @@ export class HttpToolkitServer extends events.EventEmitter {
180180
// and override the port from 4000 to something less likely to conflict.
181181
port: { port: 45457, host: '127.0.0.1' },
182182
playground: false,
183-
cors: { origin: ALLOWED_ORIGINS }
183+
cors: {
184+
origin: ALLOWED_ORIGINS,
185+
maxAge: 86400 // Cache this result for as long as possible
186+
}
184187
});
185188
}
186189
};

src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ export async function runHTK(options: {
7070
cors: false,
7171
https: httpsConfig
7272
},
73-
corsOptions: { origin: ALLOWED_ORIGINS }
73+
corsOptions: {
74+
origin: ALLOWED_ORIGINS,
75+
maxAge: 86400 // Cache this result for as long as possible
76+
}
7477
});
7578
standalone.start({
7679
port: 45456,

0 commit comments

Comments
 (0)