0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Added consistency in oembed request timeouts and user-agent

no issue

- we were using the `Ghost` user agent when making the initial page request but not when making a subsequent rel="alternate" oembed request
- added a 2sec timeout to the rel="alternate" oembed request to match the initial page request
This commit is contained in:
Kevin Ansfield 2020-04-07 14:47:09 +01:00
parent 6ddce262be
commit 98e8097340
2 changed files with 10 additions and 2 deletions

View file

@ -117,7 +117,11 @@ function fetchOembedData(_url) {
// fetch oembed response from embedded rel="alternate" url
return request(oembedUrl, {
method: 'GET',
json: true
json: true,
timeout: 2 * 1000,
headers: {
'user-agent': 'Ghost(https://github.com/TryGhost/Ghost)'
}
}).then((response) => {
// validate the fetched json against the oembed spec to avoid
// leaking non-oembed responses

View file

@ -112,7 +112,11 @@ function fetchOembedData(_url) {
// fetch oembed response from embedded rel="alternate" url
return request(oembedUrl, {
method: 'GET',
json: true
json: true,
timeout: 2 * 1000,
headers: {
'user-agent': 'Ghost(https://github.com/TryGhost/Ghost)'
}
}).then((response) => {
// validate the fetched json against the oembed spec to avoid
// leaking non-oembed responses