Enabling service worker using workbox

Working on a react PWA that uses webpack as build system. For service worker we are using workbox version 2.1.2.

Made sure new service worker got loaded. When the API call return with status as 200, there is NO cache apis created under cache storage. Hence it's not working offline too, see No cache "apis" Verified the following,

API: http://localhost:5000/dist/abc/123

API to which call is made, http://localhost:5000/dist/abc/123/. Note that it's cross-site call, base page from which the call is made is http://localhost:8000. As mentioned before the API call is successful and returns response with status 200.

I am pretty new to serviceworker/workbox. Any directions on this is much appreciated.

Upvotes: 0

Views: 840

Answers (1)

nsaboo
nsaboo

Reputation: 31

You should try running your app with https and also pass cors parameter in your options

As referred in mdn docs https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API

Upvotes: 1

Related Questions