authscape 1.0.728 → 1.0.730

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.
package/index.js CHANGED
@@ -9508,30 +9508,34 @@ function generateSitemap(_x, _x2, _x3) {
9508
9508
  */
9509
9509
  function _generateSitemap() {
9510
9510
  _generateSitemap = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(req, res, apiUri) {
9511
- var protocol, host, domain, encodedDomain, response, sitemap;
9511
+ var host, domain, encodedDomain, response, sitemap;
9512
9512
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
9513
9513
  while (1) switch (_context2.prev = _context2.next) {
9514
9514
  case 0:
9515
9515
  _context2.prev = 0;
9516
9516
  // Get the domain from the request
9517
- // Check multiple headers to determine the protocol
9518
- protocol = req.headers['x-forwarded-proto'] || req.headers['x-forwarded-protocol'] || (req.connection && req.connection.encrypted ? 'https' : null) || (req.headers.referer && req.headers.referer.startsWith('https') ? 'https' : null) || 'https'; // Default to https as most production sites use SSL
9519
- host = req.headers.host;
9520
- domain = "".concat(protocol, "://").concat(host); // URL encode the domain for the API request
9517
+ host = req.headers.host; // Determine protocol - same logic as PrivateLabelPageModule
9518
+ if (host.includes("localhost")) {
9519
+ domain = "http://" + host;
9520
+ } else {
9521
+ domain = "https://" + host;
9522
+ }
9523
+
9524
+ // URL encode the domain for the API request
9521
9525
  encodedDomain = encodeURIComponent(domain); // Make a basic HTTP GET request to AuthScape API
9522
- _context2.next = 7;
9526
+ _context2.next = 6;
9523
9527
  return fetch("".concat(apiUri, "/api/Sitemap?domain=").concat(encodedDomain));
9524
- case 7:
9528
+ case 6:
9525
9529
  response = _context2.sent;
9526
9530
  if (response.ok) {
9527
- _context2.next = 10;
9531
+ _context2.next = 9;
9528
9532
  break;
9529
9533
  }
9530
9534
  throw new Error("API request failed with status ".concat(response.status));
9531
- case 10:
9532
- _context2.next = 12;
9535
+ case 9:
9536
+ _context2.next = 11;
9533
9537
  return response.text();
9534
- case 12:
9538
+ case 11:
9535
9539
  sitemap = _context2.sent;
9536
9540
  // Set the appropriate headers for XML
9537
9541
  res.setHeader('Content-Type', 'text/xml; charset=utf-8');
@@ -9543,8 +9547,8 @@ function _generateSitemap() {
9543
9547
  return _context2.abrupt("return", {
9544
9548
  props: {}
9545
9549
  });
9546
- case 20:
9547
- _context2.prev = 20;
9550
+ case 19:
9551
+ _context2.prev = 19;
9548
9552
  _context2.t0 = _context2["catch"](0);
9549
9553
  console.error('AuthScape Sitemap Error:', _context2.t0);
9550
9554
 
@@ -9556,11 +9560,11 @@ function _generateSitemap() {
9556
9560
  return _context2.abrupt("return", {
9557
9561
  props: {}
9558
9562
  });
9559
- case 28:
9563
+ case 27:
9560
9564
  case "end":
9561
9565
  return _context2.stop();
9562
9566
  }
9563
- }, _callee2, null, [[0, 20]]);
9567
+ }, _callee2, null, [[0, 19]]);
9564
9568
  }));
9565
9569
  return _generateSitemap.apply(this, arguments);
9566
9570
  }
@@ -9577,10 +9581,10 @@ function createSitemapHandler(apiUri) {
9577
9581
  _context.next = 9;
9578
9582
  break;
9579
9583
  }
9580
- console.error('AuthScape Sitemap Error: apiUri is not configured');
9584
+ console.error('AuthScape Sitemap Error: apiUri is not configured. Please set process.env.apiUri in your .env.local file or environment variables.');
9581
9585
  res.statusCode = 500;
9582
9586
  res.setHeader('Content-Type', 'text/plain');
9583
- res.write('Sitemap configuration error: API URI not set');
9587
+ res.write('Sitemap configuration error: API URI not set. Please configure process.env.apiUri in your environment variables.');
9584
9588
  res.end();
9585
9589
  return _context.abrupt("return", {
9586
9590
  props: {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authscape",
3
- "version": "1.0.728",
3
+ "version": "1.0.730",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -13,16 +13,15 @@
13
13
  export async function generateSitemap(req, res, apiUri) {
14
14
  try {
15
15
  // Get the domain from the request
16
- // Check multiple headers to determine the protocol
17
- const protocol =
18
- req.headers['x-forwarded-proto'] ||
19
- req.headers['x-forwarded-protocol'] ||
20
- (req.connection && req.connection.encrypted ? 'https' : null) ||
21
- (req.headers.referer && req.headers.referer.startsWith('https') ? 'https' : null) ||
22
- 'https'; // Default to https as most production sites use SSL
23
-
24
16
  const host = req.headers.host;
25
- const domain = `${protocol}://${host}`;
17
+
18
+ // Determine protocol - same logic as PrivateLabelPageModule
19
+ let domain;
20
+ if (host.includes("localhost")) {
21
+ domain = "http://" + host;
22
+ } else {
23
+ domain = "https://" + host;
24
+ }
26
25
 
27
26
  // URL encode the domain for the API request
28
27
  const encodedDomain = encodeURIComponent(domain);
@@ -75,10 +74,10 @@ export function createSitemapHandler(apiUri) {
75
74
  const apiBaseUri = apiUri || process.env.apiUri;
76
75
 
77
76
  if (!apiBaseUri) {
78
- console.error('AuthScape Sitemap Error: apiUri is not configured');
77
+ console.error('AuthScape Sitemap Error: apiUri is not configured. Please set process.env.apiUri in your .env.local file or environment variables.');
79
78
  res.statusCode = 500;
80
79
  res.setHeader('Content-Type', 'text/plain');
81
- res.write('Sitemap configuration error: API URI not set');
80
+ res.write('Sitemap configuration error: API URI not set. Please configure process.env.apiUri in your environment variables.');
82
81
  res.end();
83
82
  return { props: {} };
84
83
  }