Skip to content

Commit ba11eb7

Browse files
committed
adbeta credentials
1 parent b6157cf commit ba11eb7

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

modules/dasBidAdapter.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,14 +335,17 @@ export const spec = {
335335
const baseUrl = getEndpoint(data.ext.network);
336336
const fullUrl = `${baseUrl}?data=${encodeURIComponent(jsonData)}`;
337337

338+
// adbeta needs credentials omitted to avoid CORS issues, especially in Firefox
339+
const useCredentials = !(!!data.ext?.adbeta);
340+
338341
// Switch to POST if URL exceeds 8k characters
339342
if (fullUrl.length > 8192) {
340343
return {
341344
method: 'POST',
342345
url: baseUrl,
343346
data: jsonData,
344347
options: {
345-
withCredentials: true,
348+
withCredentials: useCredentials,
346349
crossOrigin: true,
347350
customHeaders: {
348351
'Content-Type': 'text/plain'
@@ -355,7 +358,7 @@ export const spec = {
355358
method: 'GET',
356359
url: fullUrl,
357360
options: {
358-
withCredentials: true,
361+
withCredentials: useCredentials,
359362
crossOrigin: true,
360363
},
361364
};

test/spec/modules/dasBidAdapter_spec.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,34 @@ describe('dasBidAdapter', function () {
265265
expect(payload.ext.network).to.equal('network1');
266266
});
267267

268+
it('should set withCredentials to false when adbeta flag is present', function () {
269+
const bidRequestsWithAdbeta = [{
270+
bidId: 'bid123',
271+
params: {
272+
site: 'site1',
273+
area: 'area1',
274+
slot: 'slot1',
275+
network: 'network1',
276+
pageContext: {}
277+
},
278+
mediaTypes: {
279+
banner: {
280+
sizes: [[300, 250]]
281+
}
282+
}
283+
}];
284+
285+
const bidderRequestWithAdbeta = {
286+
bidderRequestId: 'reqId123',
287+
ortb2: {},
288+
adbeta: true
289+
};
290+
291+
const request = spec.buildRequests(bidRequestsWithAdbeta, bidderRequestWithAdbeta);
292+
293+
expect(request.options.withCredentials).to.be.false;
294+
});
295+
268296
describe('interpretResponse', function () {
269297
const serverResponse = {
270298
body: {

0 commit comments

Comments
 (0)