@@ -7,12 +7,6 @@ const HttpProxyMiddlware = require("http-proxy-middleware");
7
7
const dfxJson = require ( "./dfx.json" ) ;
8
8
require ( "dotenv" ) . config ( ) ;
9
9
10
- let localCanister ;
11
-
12
- try {
13
- localCanister = require ( "./.dfx/local/canister_ids.json" ) . internet_identity . local ;
14
- } catch { }
15
-
16
10
/**
17
11
* Generate a webpack configuration for a canister.
18
12
*/
@@ -46,6 +40,15 @@ function generateWebpackConfigForCanister(name, info) {
46
40
devServer : {
47
41
onBeforeSetupMiddleware : ( devServer ) => {
48
42
let replicaHost = "http://localhost:8000" ; // TODO from file
43
+ const canisterIdsJson = './.dfx/local/canister_ids.json' ;
44
+
45
+ let canisterId ;
46
+
47
+ try {
48
+ canisterId = require ( canisterIdsJson ) . internet_identity . local ;
49
+ } catch ( e ) {
50
+ throw Error ( `Could get canister ID from ${ canisterIdsJson } : ${ e } ` ) ;
51
+ }
49
52
50
53
console . log ( "I am run" ) ;
51
54
// basically everything _except_ for index.js, because we want live reload
@@ -60,22 +63,19 @@ function generateWebpackConfigForCanister(name, info) {
60
63
queryParamsString += `${ params } &` ;
61
64
}
62
65
63
- queryParamsString += `canisterId=${ localCanister } ` ;
66
+ queryParamsString += `canisterId=${ canisterId } ` ;
64
67
65
68
return path + queryParamsString ;
66
69
} ,
67
70
68
71
} ) ) ;
69
72
} ,
70
73
port : 8080 ,
71
- // TODO: why does /authorize redirect to 8081?
72
- //
73
74
proxy : {
75
+ // Make sure /api calls land on the replica (and not on webpack)
74
76
"/api" : "http://localhost:8000" ,
75
- "/authorize" : "http://localhost:8081" ,
76
77
} ,
77
78
allowedHosts : [ ".localhost" , ".local" , ".ngrok.io" ] ,
78
- //historyApiFallback: true, // makes sure our index is served on all endpoints, e.g. `/faq`
79
79
} ,
80
80
81
81
// Depending in the language or framework you are using for
@@ -107,7 +107,6 @@ function generateWebpackConfigForCanister(name, info) {
107
107
process : require . resolve ( "process/browser" ) ,
108
108
} ) ,
109
109
new webpack . EnvironmentPlugin ( {
110
- "CANISTER_ID" : localCanister ,
111
110
"II_ENV" : "production"
112
111
} ) ,
113
112
new CompressionPlugin ( {
0 commit comments