falsandtru / pjax-api

The advanced PJAX superior to SPA.
https://falsandtru.github.io/pjax-api/
Apache License 2.0
318 stars 28 forks source link

Error when Cache-Control is not set #40

Closed hjr3 closed 5 years ago

hjr3 commented 5 years ago

I get the following error when Cache-Control header is not set:

Uncaught TypeError: Cannot read property 'trim' of null
    at pjax-api.js:3905
    at pjax-api.js:655
    at Either.thunk (pjax-api.js:667)
    at Either.evaluate (pjax-api.js:800)
    at Either.thunk (pjax-api.js:662)
    at Either.evaluate (pjax-api.js:800)
    at Either.thunk (pjax-api.js:662)
    at Either.evaluate (pjax-api.js:800)
    at Either.extract (pjax-api.js:679)
    at Either.extract (pjax-api.js:679)

Example response:

HTTP/1.1 200 OK
ETag: W/"1500-bBhQrFKrKDiHMxhJ8mHxWb5w21U"
Date: Fri, 17 May 2019 21:38:24 GMT
Connection: keep-alive

Express is setting the ETag header but does not automatically set the Cache-Control header. The work around is to set a Cache-Control header.

I believe the issue is that Cache-Control is not being defaulted to '' on this line, but is defaulted to '' just above in the if check.

falsandtru commented 5 years ago

Thanks, I published the current fixed code to npm as v3.29.6.

hjr3 commented 5 years ago

Thank you for the quick response and great library!

On Fri, May 17, 2019 at 21:40 falsandtru notifications@github.com wrote:

Thanks, I published the current fixed code to npm as v3.29.6.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/falsandtru/pjax-api/issues/40?email_source=notifications&email_token=AAAIEJXON2M2ITX6OIWCDXDPV6CEPA5CNFSM4HNYTBF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVWHQAA#issuecomment-493647872, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAIEJS2JRNB74ESIQMTW5TPV6CEPANCNFSM4HNYTBFQ .