aotrautils-srv 0.0.305 → 0.0.307

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
 
2
2
 
3
- /*utils COMMONS library associated with aotra version : «1_29072022-2359 (03/12/2022-16:04:15)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (03/12/2022-16:28:12)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -4827,7 +4827,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
4827
4827
 
4828
4828
 
4829
4829
 
4830
- /*utils SERVER library associated with aotra version : «1_29072022-2359 (03/12/2022-16:04:15)»*/
4830
+ /*utils SERVER library associated with aotra version : «1_29072022-2359 (03/12/2022-16:28:12)»*/
4831
4831
  /*-----------------------------------------------------------------------------*/
4832
4832
 
4833
4833
 
@@ -5866,9 +5866,6 @@ launchNodeHTTPServer=function(port, doOnConnect=null, doOnFinalizeServer=null, /
5866
5866
  }
5867
5867
 
5868
5868
 
5869
- // To remove the CORS error message (cf. https://medium.com/@dtkatz/3-ways-to-fix-the-cors-error-and-how-access-control-allow-origin-works-d97d55946d9)
5870
- if(ADD_CORS_HEADER) response.header('Access-Control-Allow-Origin', '*');
5871
-
5872
5869
 
5873
5870
  const urlFile="." + url;
5874
5871
 
@@ -5877,6 +5874,12 @@ launchNodeHTTPServer=function(port, doOnConnect=null, doOnFinalizeServer=null, /
5877
5874
 
5878
5875
  let contentType="text/html";
5879
5876
 
5877
+ const headers={ "Content-Type": contentType };
5878
+
5879
+ // To remove the CORS error message (cf. https://medium.com/@dtkatz/3-ways-to-fix-the-cors-error-and-how-access-control-allow-origin-works-d97d55946d9)
5880
+ if(ADD_CORS_HEADER) headers["Access-Control-Allow-Origin"]="*";
5881
+
5882
+
5880
5883
  fs.readFile(filePath, function(error, fileContent){
5881
5884
  if(error){
5882
5885
  if(error.code=="ENOENT"){
@@ -5884,7 +5887,7 @@ launchNodeHTTPServer=function(port, doOnConnect=null, doOnFinalizeServer=null, /
5884
5887
  console.log("ERROR 404 file not found :"+filePath);
5885
5888
 
5886
5889
  fs.readFile("./404.html", function(error, fileContent){
5887
- response.writeHead(200, { "Content-Type": contentType });
5890
+ response.writeHead(200, headers);
5888
5891
  response.end(fileContent, "utf-8");
5889
5892
  });
5890
5893
 
@@ -5904,7 +5907,8 @@ launchNodeHTTPServer=function(port, doOnConnect=null, doOnFinalizeServer=null, /
5904
5907
  // TRACE
5905
5908
  console.log("INFO 200 OK :"+filePath);
5906
5909
 
5907
- response.writeHead(200, { "Content-Type": contentType });
5910
+
5911
+ response.writeHead(200, headers);
5908
5912
  response.end(fileContent, "utf-8");
5909
5913
 
5910
5914
  // res.writeHead(200);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.305",
3
+ "version": "0.0.307",
4
4
  "main": "aotrautils-srv.build.js",
5
5
  "description": "A library for vanilla javascript utils (server-side) used in aotra javascript CMS",
6
6
  "author": "Jeremie Ratomposon <info@alqemia.com> (https://alqemia.com)",