authscape 1.0.726 → 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 +21 -16
- package/package.json +1 -1
- package/src/services/sitemapService.js +10 -4
package/index.js
CHANGED
|
@@ -9508,29 +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
|
|
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
|
-
|
|
9518
|
-
host
|
|
9519
|
-
|
|
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
|
|
9520
9525
|
encodedDomain = encodeURIComponent(domain); // Make a basic HTTP GET request to AuthScape API
|
|
9521
|
-
_context2.next =
|
|
9526
|
+
_context2.next = 6;
|
|
9522
9527
|
return fetch("".concat(apiUri, "/api/Sitemap?domain=").concat(encodedDomain));
|
|
9523
|
-
case
|
|
9528
|
+
case 6:
|
|
9524
9529
|
response = _context2.sent;
|
|
9525
9530
|
if (response.ok) {
|
|
9526
|
-
_context2.next =
|
|
9531
|
+
_context2.next = 9;
|
|
9527
9532
|
break;
|
|
9528
9533
|
}
|
|
9529
9534
|
throw new Error("API request failed with status ".concat(response.status));
|
|
9530
|
-
case
|
|
9531
|
-
_context2.next =
|
|
9535
|
+
case 9:
|
|
9536
|
+
_context2.next = 11;
|
|
9532
9537
|
return response.text();
|
|
9533
|
-
case
|
|
9538
|
+
case 11:
|
|
9534
9539
|
sitemap = _context2.sent;
|
|
9535
9540
|
// Set the appropriate headers for XML
|
|
9536
9541
|
res.setHeader('Content-Type', 'text/xml; charset=utf-8');
|
|
@@ -9542,8 +9547,8 @@ function _generateSitemap() {
|
|
|
9542
9547
|
return _context2.abrupt("return", {
|
|
9543
9548
|
props: {}
|
|
9544
9549
|
});
|
|
9545
|
-
case
|
|
9546
|
-
_context2.prev =
|
|
9550
|
+
case 19:
|
|
9551
|
+
_context2.prev = 19;
|
|
9547
9552
|
_context2.t0 = _context2["catch"](0);
|
|
9548
9553
|
console.error('AuthScape Sitemap Error:', _context2.t0);
|
|
9549
9554
|
|
|
@@ -9555,11 +9560,11 @@ function _generateSitemap() {
|
|
|
9555
9560
|
return _context2.abrupt("return", {
|
|
9556
9561
|
props: {}
|
|
9557
9562
|
});
|
|
9558
|
-
case
|
|
9563
|
+
case 27:
|
|
9559
9564
|
case "end":
|
|
9560
9565
|
return _context2.stop();
|
|
9561
9566
|
}
|
|
9562
|
-
}, _callee2, null, [[0,
|
|
9567
|
+
}, _callee2, null, [[0, 19]]);
|
|
9563
9568
|
}));
|
|
9564
9569
|
return _generateSitemap.apply(this, arguments);
|
|
9565
9570
|
}
|
|
@@ -9576,10 +9581,10 @@ function createSitemapHandler(apiUri) {
|
|
|
9576
9581
|
_context.next = 9;
|
|
9577
9582
|
break;
|
|
9578
9583
|
}
|
|
9579
|
-
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.');
|
|
9580
9585
|
res.statusCode = 500;
|
|
9581
9586
|
res.setHeader('Content-Type', 'text/plain');
|
|
9582
|
-
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.');
|
|
9583
9588
|
res.end();
|
|
9584
9589
|
return _context.abrupt("return", {
|
|
9585
9590
|
props: {}
|
package/package.json
CHANGED
|
@@ -13,9 +13,15 @@
|
|
|
13
13
|
export async function generateSitemap(req, res, apiUri) {
|
|
14
14
|
try {
|
|
15
15
|
// Get the domain from the request
|
|
16
|
-
const protocol = req.headers['x-forwarded-proto'] || 'http';
|
|
17
16
|
const host = req.headers.host;
|
|
18
|
-
|
|
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
|
+
}
|
|
19
25
|
|
|
20
26
|
// URL encode the domain for the API request
|
|
21
27
|
const encodedDomain = encodeURIComponent(domain);
|
|
@@ -68,10 +74,10 @@ export function createSitemapHandler(apiUri) {
|
|
|
68
74
|
const apiBaseUri = apiUri || process.env.apiUri;
|
|
69
75
|
|
|
70
76
|
if (!apiBaseUri) {
|
|
71
|
-
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.');
|
|
72
78
|
res.statusCode = 500;
|
|
73
79
|
res.setHeader('Content-Type', 'text/plain');
|
|
74
|
-
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.');
|
|
75
81
|
res.end();
|
|
76
82
|
return { props: {} };
|
|
77
83
|
}
|