Skip to content

Commit e5ef7ba

Browse files
authored
Merge pull request #267 from BrasilAPI/fix-correios-alt
Atualiza o provedor correios-alt
2 parents 73133eb + 320fcfe commit e5ef7ba

File tree

3 files changed

+26
-24
lines changed

3 files changed

+26
-24
lines changed

src/services/correios-alt.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ export default function fetchCorreiosAltAPIService(
77
cepWithLeftPad,
88
configurations
99
) {
10-
const url = 'https://buscacepinter.correios.com.br/app/cep/carrega-cep.php'
10+
const url = 'https://buscacepinter.correios.com.br/app/endereco/carrega-cep-endereco.php'
1111
const options = {
1212
method: 'POST',
1313
mode: 'cors',
1414
headers: {
15-
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'
15+
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
16+
'Referer': 'https://buscacepinter.correios.com.br/app/endereco/index.php',
17+
'Referrer-Policy': 'strict-origin-when-cross-origin'
1618
},
17-
body: `cep=${cepWithLeftPad}`,
19+
body: `endereco=${cepWithLeftPad}&tipoCEP=ALL`,
1820
timeout: configurations.timeout || 30000
1921
}
2022

test/unit/cep-promise-node.spec.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('[unit] cep-promise for node', () => {
3535
)
3636

3737
nock('https://buscacepinter.correios.com.br')
38-
.post('/app/cep/carrega-cep.php')
38+
.post('/app/endereco/carrega-cep-endereco.php')
3939
.replyWithFile(
4040
200,
4141
path.join(__dirname, '/fixtures/correios-alt-cep-05010000-found.json')
@@ -164,7 +164,7 @@ describe('[unit] cep-promise for node', () => {
164164
)
165165

166166
nock('https://buscacepinter.correios.com.br')
167-
.post('/app/cep/carrega-cep.php')
167+
.post('/app/endereco/carrega-cep-endereco.php')
168168
.replyWithFile(
169169
200,
170170
path.join(__dirname, '/fixtures/correios-alt-cep-05010000-found.json')
@@ -214,7 +214,7 @@ describe('[unit] cep-promise for node', () => {
214214
)
215215

216216
nock('https://buscacepinter.correios.com.br')
217-
.post('/app/cep/carrega-cep.php')
217+
.post('/app/endereco/carrega-cep-endereco.php')
218218
.replyWithFile(
219219
200,
220220
path.join(__dirname, '/fixtures/correios-alt-cep-05010000-found.json')
@@ -264,7 +264,7 @@ describe('[unit] cep-promise for node', () => {
264264
)
265265

266266
nock('https://buscacepinter.correios.com.br')
267-
.post('/app/cep/carrega-cep.php')
267+
.post('/app/endereco/carrega-cep-endereco.php')
268268
.replyWithFile(
269269
200,
270270
path.join(__dirname, '/fixtures/correios-alt-cep-99999999-error.json')
@@ -315,7 +315,7 @@ describe('[unit] cep-promise for node', () => {
315315
)
316316

317317
nock('https://buscacepinter.correios.com.br')
318-
.post('/app/cep/carrega-cep.php')
318+
.post('/app/endereco/carrega-cep-endereco.php')
319319
.replyWithFile(
320320
200,
321321
path.join(__dirname, '/fixtures/correios-alt-cep-05010000-found.json')
@@ -366,7 +366,7 @@ describe('[unit] cep-promise for node', () => {
366366
)
367367

368368
nock('https://buscacepinter.correios.com.br')
369-
.post('/app/cep/carrega-cep.php')
369+
.post('/app/endereco/carrega-cep-endereco.php')
370370
.replyWithFile(
371371
200,
372372
path.join(__dirname, '/fixtures/correios-alt-cep-99999999-error.json')
@@ -416,7 +416,7 @@ describe('[unit] cep-promise for node', () => {
416416
)
417417

418418
nock('https://buscacepinter.correios.com.br')
419-
.post('/app/cep/carrega-cep.php')
419+
.post('/app/endereco/carrega-cep-endereco.php')
420420
.replyWithFile(
421421
200,
422422
path.join(__dirname, '/fixtures/correios-alt-cep-99999999-error.json')
@@ -465,7 +465,7 @@ describe('[unit] cep-promise for node', () => {
465465
)
466466

467467
nock('https://buscacepinter.correios.com.br')
468-
.post('/app/cep/carrega-cep.php')
468+
.post('/app/endereco/carrega-cep-endereco.php')
469469
.replyWithFile(
470470
200,
471471
path.join(__dirname, '/fixtures/correios-alt-cep-99999999-error.json')
@@ -514,7 +514,7 @@ describe('[unit] cep-promise for node', () => {
514514
)
515515

516516
nock('https://buscacepinter.correios.com.br')
517-
.post('/app/cep/carrega-cep.php')
517+
.post('/app/endereco/carrega-cep-endereco.php')
518518
.replyWithFile(
519519
200,
520520
path.join(__dirname, '/fixtures/correios-alt-cep-05010000-found.json')
@@ -562,7 +562,7 @@ describe('[unit] cep-promise for node', () => {
562562
)
563563

564564
nock('https://buscacepinter.correios.com.br')
565-
.post('/app/cep/carrega-cep.php')
565+
.post('/app/endereco/carrega-cep-endereco.php')
566566
.replyWithFile(
567567
200,
568568
path.join(__dirname, '/fixtures/correios-alt-cep-05010000-found.json')
@@ -611,7 +611,7 @@ describe('[unit] cep-promise for node', () => {
611611
)
612612

613613
nock('https://buscacepinter.correios.com.br')
614-
.post('/app/cep/carrega-cep.php')
614+
.post('/app/endereco/carrega-cep-endereco.php')
615615
.replyWithFile(
616616
200,
617617
path.join(__dirname, '/fixtures/correios-alt-cep-99999999-error.json')
@@ -697,7 +697,7 @@ describe('[unit] cep-promise for node', () => {
697697
)
698698

699699
nock('https://buscacepinter.correios.com.br')
700-
.post('/app/cep/carrega-cep.php')
700+
.post('/app/endereco/carrega-cep-endereco.php')
701701
.reply(400, '<h2>Bad Request (400)</h2>')
702702

703703
nock('https://viacep.com.br')
@@ -757,7 +757,7 @@ describe('[unit] cep-promise for node', () => {
757757
)
758758

759759
nock('https://buscacepinter.correios.com.br')
760-
.post('/app/cep/carrega-cep.php')
760+
.post('/app/endereco/carrega-cep-endereco.php')
761761
.reply(200, {erro:true})
762762

763763
nock('https://viacep.com.br')
@@ -816,7 +816,7 @@ describe('[unit] cep-promise for node', () => {
816816
)
817817

818818
nock('https://buscacepinter.correios.com.br')
819-
.post('/app/cep/carrega-cep.php')
819+
.post('/app/endereco/carrega-cep-endereco.php')
820820
.reply(200, {erro:true})
821821

822822
nock('https://viacep.com.br')

test/unit/cep-promise-providers.spec.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ describe('when invoked with providers parameter', () => {
130130
)
131131

132132
const correiosAltMock = nock('https://buscacepinter.correios.com.br')
133-
.post('/app/cep/carrega-cep.php')
133+
.post('/app/endereco/carrega-cep-endereco.php')
134134
.replyWithFile(
135135
200,
136136
path.join(__dirname, '/fixtures/correios-alt-cep-05010000-found.json')
@@ -179,7 +179,7 @@ describe('when invoked with providers parameter', () => {
179179
)
180180

181181
const correiosAltMock = nock('https://buscacepinter.correios.com.br')
182-
.post('/app/cep/carrega-cep.php')
182+
.post('/app/endereco/carrega-cep-endereco.php')
183183
.replyWithFile(
184184
200,
185185
path.join(__dirname, '/fixtures/correios-alt-cep-05010000-found.json')
@@ -228,7 +228,7 @@ describe('when invoked with providers parameter', () => {
228228
)
229229

230230
const correiosAltMock = nock('https://buscacepinter.correios.com.br')
231-
.post('/app/cep/carrega-cep.php')
231+
.post('/app/endereco/carrega-cep-endereco.php')
232232
.replyWithFile(
233233
200,
234234
path.join(__dirname, '/fixtures/correios-alt-cep-05010000-found.json')
@@ -277,7 +277,7 @@ describe('when invoked with providers parameter', () => {
277277
)
278278

279279
const correiosAltMock = nock('https://buscacepinter.correios.com.br')
280-
.post('/app/cep/carrega-cep.php')
280+
.post('/app/endereco/carrega-cep-endereco.php')
281281
.replyWithFile(
282282
200,
283283
path.join(__dirname, '/fixtures/correios-alt-cep-05010000-found.json')
@@ -326,7 +326,7 @@ describe('when invoked with providers parameter', () => {
326326
)
327327

328328
const correiosAltMock = nock('https://buscacepinter.correios.com.br')
329-
.post('/app/cep/carrega-cep.php')
329+
.post('/app/endereco/carrega-cep-endereco.php')
330330
.replyWithFile(
331331
200,
332332
path.join(__dirname, '/fixtures/correios-alt-cep-05010000-found.json')
@@ -383,7 +383,7 @@ describe('when invoked with providers parameter', () => {
383383
)
384384

385385
const correiosAltMock = nock('https://buscacepinter.correios.com.br')
386-
.post('/app/cep/carrega-cep.php')
386+
.post('/app/endereco/carrega-cep-endereco.php')
387387
.replyWithFile(
388388
200,
389389
path.join(__dirname, '/fixtures/correios-alt-cep-05010000-found.json')
@@ -432,7 +432,7 @@ describe('when invoked with providers parameter', () => {
432432
)
433433

434434
const correiosAltMock = nock('https://buscacepinter.correios.com.br')
435-
.post('/app/cep/carrega-cep.php')
435+
.post('/app/endereco/carrega-cep-endereco.php')
436436
.replyWithFile(
437437
200,
438438
path.join(__dirname, '/fixtures/correios-alt-cep-05010000-found.json')

0 commit comments

Comments
 (0)