Skip to content

Commit e7e95f4

Browse files
ianwiedsclaude
andcommitted
Allow authorizedFetch to proceed without authenticated user
Instead of throwing an error when no user is logged in, authorizedFetch now logs a warning and proceeds with the fetch without the Authorization header. This allows endpoints that support both authenticated and unauthenticated requests to work seamlessly. Bump to v1.0.8. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5b41b67 commit e7e95f4

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ultimate-jekyll-manager",
3-
"version": "1.0.7",
3+
"version": "1.0.8",
44
"description": "Ultimate Jekyll dependency manager",
55
"main": "dist/index.js",
66
"exports": {
@@ -79,7 +79,7 @@
7979
"cheerio": "^1.2.0",
8080
"chrome-launcher": "^1.2.1",
8181
"dotenv": "^17.3.1",
82-
"fast-xml-parser": "^5.5.7",
82+
"fast-xml-parser": "^5.5.8",
8383
"fs-jetpack": "^5.1.0",
8484
"glob": "^13.0.6",
8585
"gulp-clean-css": "^4.3.0",

src/assets/js/libs/authorized-fetch.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,19 @@ export async function authorizedFetch(url, options = {}) {
2020
const user = auth.currentUser;
2121

2222
if (!user) {
23-
console.warn('Did we fully wait for auth state to be determined?');
24-
throw new Error('No authenticated user found');
23+
console.warn('authorizedFetch: No authenticated user found. Did we fully wait for auth state to be determined?');
2524
}
2625

27-
// Get the ID token - let it throw if it fails
28-
const idToken = await user.getIdToken(true);
29-
3026
// Ensure headers object exists
3127
if (!requestOptions.headers) {
3228
requestOptions.headers = {};
3329
}
3430

35-
// Set the Authorization header with Bearer token
36-
requestOptions.headers['Authorization'] = `Bearer ${idToken}`;
31+
// Set the Authorization header with Bearer token if user is logged in
32+
if (user) {
33+
const idToken = await user.getIdToken(true);
34+
requestOptions.headers['Authorization'] = `Bearer ${idToken}`;
35+
}
3736

3837
// Make the request using wonderful-fetch
3938
return fetch(url, requestOptions);

0 commit comments

Comments
 (0)