【发布时间】:2022-06-18 07:33:19
【问题描述】:
这已经在生产环境中运行了大约 6 个月,但突然停止工作。
我想让用户在 FIFA 上搜索他们的 Pro Club。没有 API,所以我点击他们的 URL 并获取数据。
这是网址:https://proclubs.ea.com/api/fifa/clubs/search?platform=ps4&clubName=cat
在本地它以 200 代码响应,但在生产上它返回 503 Service Unavailable 错误
有人对如何排除故障有任何建议吗?我想知道我是否缺少标题,但奇怪的是它已经工作了这么长时间。会不会是 EA 屏蔽了我?
这是我的代码:
const eaClubsAxios = axios.create({
baseURL: `https://proclubs.ea.com/api/fifa/clubs/search?platform=${platform}&clubName=${searchterm}`,
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36',
'Referer': 'https://www.ea.com/'
},
});
const getEaClubs = async () => {
const eaClubs = await eaClubsAxios.get('');
console.log({ eaClubs })
return eaClubs.data;
};
这是来自本地的“eaClubs”的控制台日志:
{
status: 200,
statusText: 'OK',
headers: {
'content-type': 'application/json',
server: 'nginx',
'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
'x-frame-options': 'DENY',
'x-xss-protection': '1; mode=block',
'x-content-type-options': 'nosniff',
'content-security-policy': "default-src 'self'",
'x-permitted-cross-domain-policies': 'master-only',
'cache-control': 'max-age=118',
expires: 'Sun, 05 Dec 2021 15:07:11 GMT',
date: 'Sun, 05 Dec 2021 15:05:13 GMT',
'content-length': '45009',
connection: 'close',
'x-environment-context': 'prod',
'x-application-context': 'proclubs',
'strict-transport-security': 'max-age=86400',
'set-cookie': [Array]
},
config: {
adapter: [Function: httpAdapter],
transformRequest: [Object],
transformResponse: [Object],
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
validateStatus: [Function: validateStatus],
headers: [Object],
method: 'get',
baseURL: 'https://proclubs.ea.com/api/fifa/clubs/search?platform=ps4&clubName=cat',
url: 'https://proclubs.ea.com/api/fifa/clubs/search?platform=ps4&clubName=cat',
data: undefined
},
request: ClientRequest {
_events: [Object: null prototype],
_eventsCount: 6,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: false,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: false,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: 0,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket: [TLSSocket],
_header: 'GET /api/fifa/clubs/search?platform=ps4&clubName=cat HTTP/1.1\r\n' +
'Accept: application/json, text/plain, */*\r\n' +
'Referer: https://www.ea.com/\r\n' +
'User-Agent: axios/0.18.0\r\n' +
'Host: proclubs.ea.com\r\n' +
'Connection: close\r\n' +
'\r\n',
_keepAliveTimeout: 0,
_onPendingData: [Function: noopPendingOutput],
agent: [Agent],
socketPath: undefined,
method: 'GET',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
path: '/api/fifa/clubs/search?platform=ps4&clubName=cat',
_ended: true,
res: [IncomingMessage],
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: 'proclubs.ea.com',
protocol: 'https:',
_redirectable: [Writable],
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype]
},
data: {
'111723': [Object]
}
}
【问题讨论】:
标签: node.js http axios http-headers