nomagick commited on
Commit
033a53a
·
unverified ·
1 Parent(s): 0f36fe8

fix: options handling in stand-alone script

Browse files
backend/functions/package-lock.json CHANGED
@@ -16,7 +16,7 @@
16
  "axios": "^1.3.3",
17
  "bcrypt": "^5.1.0",
18
  "busboy": "^1.6.0",
19
- "civkit": "^0.8.2-03243fe",
20
  "core-js": "^3.37.1",
21
  "cors": "^2.8.5",
22
  "dayjs": "^1.11.9",
@@ -3979,10 +3979,9 @@
3979
  }
3980
  },
3981
  "node_modules/civkit": {
3982
- "version": "0.8.2-03243fe",
3983
- "resolved": "https://registry.npmjs.org/civkit/-/civkit-0.8.2-03243fe.tgz",
3984
- "integrity": "sha512-hoTxGeGdD27iOCDi51cVY0PHlRN3OSC640QRJ1YSmD42o+LP7mZtbdy8dN7j/FSkPP/5yLuB2ch9BMSOp54POQ==",
3985
- "license": "AGPL",
3986
  "dependencies": {
3987
  "lodash": "^4.17.21",
3988
  "tslib": "^2.5.0"
 
16
  "axios": "^1.3.3",
17
  "bcrypt": "^5.1.0",
18
  "busboy": "^1.6.0",
19
+ "civkit": "^0.8.3-3e69606",
20
  "core-js": "^3.37.1",
21
  "cors": "^2.8.5",
22
  "dayjs": "^1.11.9",
 
3979
  }
3980
  },
3981
  "node_modules/civkit": {
3982
+ "version": "0.8.3-3e69606",
3983
+ "resolved": "https://registry.npmjs.org/civkit/-/civkit-0.8.3-3e69606.tgz",
3984
+ "integrity": "sha512-niV5U11ySIiVNSnGpW49KJlExmIiuQQfnyQEXeYuKCE+B+wkqYCBG+3tlY3E882tmPkaQQKpDlF/yTeqEU2q2Q==",
 
3985
  "dependencies": {
3986
  "lodash": "^4.17.21",
3987
  "tslib": "^2.5.0"
backend/functions/package.json CHANGED
@@ -36,7 +36,7 @@
36
  "axios": "^1.3.3",
37
  "bcrypt": "^5.1.0",
38
  "busboy": "^1.6.0",
39
- "civkit": "^0.8.2-03243fe",
40
  "core-js": "^3.37.1",
41
  "cors": "^2.8.5",
42
  "dayjs": "^1.11.9",
 
36
  "axios": "^1.3.3",
37
  "bcrypt": "^5.1.0",
38
  "busboy": "^1.6.0",
39
+ "civkit": "^0.8.3-3e69606",
40
  "core-js": "^3.37.1",
41
  "cors": "^2.8.5",
42
  "dayjs": "^1.11.9",
backend/functions/src/stand-alone/crawl.ts CHANGED
@@ -98,6 +98,16 @@ export class CrawlStandAloneServer extends ExpressServer {
98
  };
99
  }
100
 
 
 
 
 
 
 
 
 
 
 
101
  override listen(port: number) {
102
  const r = super.listen(port);
103
  if (this.httpAlternativeServer) {
@@ -132,7 +142,12 @@ export class CrawlStandAloneServer extends ExpressServer {
132
  res.end(JSON.stringify(content));
133
  });
134
 
135
- this.expressRootRouter.use('/', ...this.registry.expressMiddlewares, this.makeAssetsServingController(), this.registry.makeShimController('crawl'));
 
 
 
 
 
136
  }
137
 
138
  protected override featureSelect(): void {
 
98
  };
99
  }
100
 
101
+ makeIgnoreOPTIONSMiddleware() {
102
+ return (req: Request, res: Response, next: NextFunction) => {
103
+ if (req.method === 'OPTIONS') {
104
+ return res.status(200).end();
105
+ }
106
+
107
+ return next();
108
+ };
109
+ }
110
+
111
  override listen(port: number) {
112
  const r = super.listen(port);
113
  if (this.httpAlternativeServer) {
 
142
  res.end(JSON.stringify(content));
143
  });
144
 
145
+ this.expressRootRouter.use('/',
146
+ ...this.registry.expressMiddlewares,
147
+ this.makeAssetsServingController(),
148
+ this.makeIgnoreOPTIONSMiddleware(),
149
+ this.registry.makeShimController('crawl')
150
+ );
151
  }
152
 
153
  protected override featureSelect(): void {
backend/functions/src/stand-alone/search.ts CHANGED
@@ -98,6 +98,16 @@ export class SearchStandAloneServer extends ExpressServer {
98
  };
99
  }
100
 
 
 
 
 
 
 
 
 
 
 
101
  override listen(port: number) {
102
  const r = super.listen(port);
103
  if (this.httpAlternativeServer) {
@@ -132,7 +142,12 @@ export class SearchStandAloneServer extends ExpressServer {
132
  res.end(JSON.stringify(content));
133
  });
134
 
135
- this.expressRootRouter.use('/', ...this.registry.expressMiddlewares, this.makeAssetsServingController(), this.registry.makeShimController('search'));
 
 
 
 
 
136
  }
137
 
138
  protected override featureSelect(): void {
 
98
  };
99
  }
100
 
101
+ makeIgnoreOPTIONSMiddleware() {
102
+ return (req: Request, res: Response, next: NextFunction) => {
103
+ if (req.method === 'OPTIONS') {
104
+ return res.status(200).end();
105
+ }
106
+
107
+ return next();
108
+ };
109
+ }
110
+
111
  override listen(port: number) {
112
  const r = super.listen(port);
113
  if (this.httpAlternativeServer) {
 
142
  res.end(JSON.stringify(content));
143
  });
144
 
145
+ this.expressRootRouter.use('/',
146
+ ...this.registry.expressMiddlewares,
147
+ this.makeIgnoreOPTIONSMiddleware(),
148
+ this.makeAssetsServingController(),
149
+ this.registry.makeShimController('search')
150
+ );
151
  }
152
 
153
  protected override featureSelect(): void {
thinapps-shared CHANGED
@@ -1 +1 @@
1
- Subproject commit 1463a18b1c039e5c0d1073998a8d6953f811406d
 
1
+ Subproject commit 34e1550a985fe416736420fd6e8dc2f7661b51be