Skip to content

Commit

Permalink
fix: processing S3_ACCESS_HOST configuration without protocol header …
Browse files Browse the repository at this point in the history
…obtained in rss acquisition #228 (#229)
  • Loading branch information
PBK-B authored Jul 26, 2024
1 parent aacb021 commit f6151e8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server/src/services/rss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export function RSSService() {
const folder = env.S3_CACHE_FOLDER || 'cache/';
return new Elysia({ aot: false })
.get('/sub/:name', async ({ set, params: { name } }) => {
if (!accessHost) {
const host = `${(accessHost.startsWith("http://") || accessHost.startsWith("https://") ? '' :'https://')}${accessHost}`;
if (!host) {
set.status = 500;
return 'S3_ACCESS_HOST is not defined'
}
Expand All @@ -33,7 +34,7 @@ export function RSSService() {
if (['rss.xml', 'atom.xml', 'rss.json'].includes(name)) {
const key = path.join(folder, name);
try {
const url = `${accessHost}/${key}`;
const url = `${host}/${key}`;
console.log(`Fetching ${url}`);
const response = await fetch(new Request(url))
const contentType = name === 'rss.xml' ? 'application/rss+xml; charset=UTF-8' : name === 'atom.xml' ? 'application/atom+xml; charset=UTF-8' : 'application/feed+json; charset=UTF-8';
Expand Down

0 comments on commit f6151e8

Please sign in to comment.