@@ -12,7 +12,15 @@ export const test = base.extend({
1212
1313 if ( browserName === "webkit" ) {
1414 // Apply routing for Safari since it doesn't support host-resolver-rules
15- await page . route ( "**/*" , ( route ) => {
15+ await page . context ( ) . route ( "**/*" , ( route ) => {
16+ // Should map the config in `vite.config.ts`
17+ const hostToCanisterName : Record < string , string > = {
18+ [ "id.ai" ] : "internet_identity" ,
19+ [ "identity.ic0.app" ] : "internet_identity" ,
20+ [ "identity.internetcomputer.org" ] : "internet_identity" ,
21+ [ "nice-name.com" ] : "test_app" ,
22+ } ;
23+
1624 const req = route . request ( ) ;
1725 const urlStr = req . url ( ) ;
1826
@@ -27,8 +35,12 @@ export const test = base.extend({
2735 return route . continue ( ) ;
2836 }
2937
30- // The vite server uses
31- const newUrl = `https://internet_identity.localhost:5173${ url . pathname } ${ url . search } ` ;
38+ const canister_name = hostToCanisterName [ url . hostname ] ;
39+ if ( ! canister_name ) {
40+ return route . continue ( ) ;
41+ }
42+ // The vite server uses the Host header and the localhost subdomain to determine where the redirect the request.
43+ const newUrl = `https://${ canister_name } .localhost:5173${ url . pathname } ${ url . search } ` ;
3244 return route . continue ( {
3345 url : newUrl ,
3446 // The vite server uses the Host header to determine where the redirect the request.
0 commit comments