fix getting 403 when parsing some rss url by setting a user agent in the request
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import Parser from 'rss-parser'
|
||||
import { Brackets } from 'typeorm'
|
||||
import { Subscription } from '../../entity/subscription'
|
||||
import { User } from '../../entity/user'
|
||||
import { getRepository } from '../../entity/utils'
|
||||
@ -31,13 +32,17 @@ import { Merge } from '../../util'
|
||||
import { analytics } from '../../utils/analytics'
|
||||
import { enqueueRssFeedFetch } from '../../utils/createTask'
|
||||
import { authorized } from '../../utils/helpers'
|
||||
import { Brackets } from 'typeorm'
|
||||
|
||||
type PartialSubscription = Omit<Subscription, 'newsletterEmail'>
|
||||
|
||||
const parser = new Parser({
|
||||
timeout: 30000, // 30 seconds
|
||||
maxRedirects: 5,
|
||||
headers: {
|
||||
// some rss feeds require user agent
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36',
|
||||
},
|
||||
})
|
||||
|
||||
export type SubscriptionsSuccessPartial = Merge<
|
||||
|
||||
@ -118,9 +118,16 @@ Sentry.GCPFunction.init({
|
||||
|
||||
const signToken = promisify(jwt.sign)
|
||||
const parser = new Parser({
|
||||
timeout: 60000, // 60 seconds
|
||||
maxRedirects: 10,
|
||||
customFields: {
|
||||
item: [['link', 'links', { keepArray: true }], 'published', 'updated'],
|
||||
},
|
||||
headers: {
|
||||
// some rss feeds require user agent
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36',
|
||||
},
|
||||
})
|
||||
|
||||
// get link following the order of preference: via, alternate, self
|
||||
|
||||
Reference in New Issue
Block a user