@@ -18,7 +18,7 @@ export class NginxController {
18
18
this . app . get ( '/nginx/config/get' , ...this . requestHandlers , this . getConfig . bind ( this ) )
19
19
this . app . get ( '/nginx/config/get-default' , ...this . requestHandlers , this . getDefaultConfig . bind ( this ) )
20
20
this . app . get ( '/nginx/config/write-default' , ...this . requestHandlers , this . writeDefaultConfig . bind ( this ) )
21
- this . app . get ( '/nginx/certificates/obtain' , ...this . requestHandlers , this . obtainCertificates . bind ( this ) )
21
+ this . app . post ( '/nginx/certificates/obtain' , ...this . requestHandlers , this . obtainCertificates . bind ( this ) )
22
22
this . app . get ( '/nginx/certificates/renew' , ...this . requestHandlers , this . renewCertificates . bind ( this ) )
23
23
log ( 'info' , 'NginxController initialized' )
24
24
}
@@ -64,9 +64,14 @@ export class NginxController {
64
64
}
65
65
66
66
private async obtainCertificates ( req : Request , res : Response ) : Promise < void > {
67
- const { success, message } = await this . nginxManager . obtainCertificates ( true )
68
- const status = success ? 200 : 500
69
- res . status ( status ) . json ( { success, message } )
67
+ if ( req . body != null && req . body . domains != null && Array . isArray ( req . body . domains ) ) {
68
+ const domains = req . body . domains
69
+ const { success, message } = await this . nginxManager . obtainCertificates ( domains , true )
70
+ const status = success ? 200 : 500
71
+ res . status ( status ) . json ( { success, message } )
72
+ } else {
73
+ res . status ( 400 ) . json ( { success : false , message : 'Invalid request body' } )
74
+ }
70
75
}
71
76
72
77
private async renewCertificates ( req : Request , res : Response ) : Promise < void > {
0 commit comments