From 7ae01fc96d23b2823cab015cbe7c6462fae71192 Mon Sep 17 00:00:00 2001 From: naveenpaul1 Date: Thu, 5 Dec 2024 11:04:13 +0530 Subject: [PATCH] NSFS | S3 throwing error for empty header and default port for STS Signed-off-by: naveenpaul1 --- src/endpoint/endpoint.js | 4 ++-- src/endpoint/s3/s3_rest.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/endpoint/endpoint.js b/src/endpoint/endpoint.js index c4c817500e..8d5a1286f2 100755 --- a/src/endpoint/endpoint.js +++ b/src/endpoint/endpoint.js @@ -197,9 +197,9 @@ async function main(options = {}) { // START S3, STS & IAM SERVERS & CERTS const http_port_s3 = options.http_port || config.ENDPOINT_PORT; const https_port_s3 = options.https_port || config.ENDPOINT_SSL_PORT; - const https_port_sts = options.https_port_sts || Number(process.env.ENDPOINT_SSL_PORT_STS) || 7443; // || (process.env.NC_NSFS_NO_DB_ENV === 'true' ? -1 : 7443); + const https_port_sts = options.https_port_sts || Number(process.env.ENDPOINT_SSL_PORT_STS) || + (process.env.NC_NSFS_NO_DB_ENV === 'true' ? -1 : 7443); const https_port_iam = options.https_port_iam || config.ENDPOINT_SSL_IAM_PORT; - await start_server_and_cert(SERVICES_TYPES_ENUM.S3, init_request_sdk, { ...options, https_port: https_port_s3, http_port: http_port_s3, virtual_hosts, bucket_logger, notification_logger }); await start_server_and_cert(SERVICES_TYPES_ENUM.STS, init_request_sdk, { https_port: https_port_sts, virtual_hosts }); diff --git a/src/endpoint/s3/s3_rest.js b/src/endpoint/s3/s3_rest.js index 48ce6a00b4..0c5f081d77 100755 --- a/src/endpoint/s3/s3_rest.js +++ b/src/endpoint/s3/s3_rest.js @@ -112,7 +112,7 @@ async function handle_request(req, res) { http_utils.set_cors_headers_s3(req, res, cors); if (req.method === 'OPTIONS') { - dbg.log1('OPTIONS!'); + dbg.log1('s3_rest : S3 request method is ', req.method); const error_code = req.headers.origin && req.headers['access-control-request-method'] ? 403 : 400; const res_headers = res.getHeaders(); // We will check if we found a matching rule - if no we will return error_code res.statusCode = res_headers['access-control-allow-origin'] && res_headers['access-control-allow-methods'] ? 200 : error_code; @@ -334,7 +334,7 @@ function _get_arn_from_req_path(req) { // we will reintreduce it together with bucket site support. function parse_bucket_and_key(req) { const { url, headers, virtual_hosts } = req; - const host = headers.host.split(':')[0]; // cutting off port + const host = headers?.host?.split(':')[0]; // cutting off port let virtual_host = null; if (host && host !== 'localhost' && !net.isIP(host)) {