File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -288,6 +288,16 @@ export class HttpToolkitServerApi extends events.EventEmitter {
288288 this . server = express ( ) ;
289289 this . server . disable ( 'x-powered-by' ) ;
290290
291+ // Allow web pages on non-local URLs (app.httptoolkit.tech, not localhost) to
292+ // send requests to this admin server too. Without this, those requests will
293+ // fail after rejected preflights in recent Chrome (from ~v102, ish? Unclear).
294+ this . server . use ( ( req , res , next ) => {
295+ if ( req . headers [ "access-control-request-private-network" ] ) {
296+ res . setHeader ( "access-control-allow-private-network" , "true" ) ;
297+ }
298+ next ( null ) ;
299+ } ) ;
300+
291301 this . server . use ( cors ( {
292302 origin : ALLOWED_ORIGINS ,
293303 maxAge : 86400 // Cache this result for as long as possible
Original file line number Diff line number Diff line change @@ -121,7 +121,8 @@ export async function runHTK(options: {
121121 corsOptions : {
122122 strict : true , // For the standalone admin API, require valid CORS headers
123123 origin : ALLOWED_ORIGINS , // Only allow requests from our origins, to avoid XSRF
124- maxAge : 86400 // Cache CORS responses for as long as possible
124+ maxAge : 86400 , // Cache CORS responses for as long as possible
125+ allowPrivateNetworkAccess : true // Allow access from non-local domains in Chrome 102+
125126 } ,
126127 webSocketKeepAlive : 20000 , // Send a keep-alive ping to Mockttp clients every minute
127128 ruleParameters // Rule parameter dictionary
You can’t perform that action at this time.
0 commit comments