pcb icon indicating copy to clipboard operation
pcb copied to clipboard

Exclude firebase path

Open itaied246 opened this issue 6 years ago • 4 comments

I am integrating firebase auth. The service working is catching the __/auth requests and don't pass them on.

How can I exclude it from catching those requests?

I tried to do this:

new OfflinePlugin({
      relativePaths: false,
      publicPath: '/',
      appShell: '/',
      excludes: ['/__/auth/**/*'],
})

But it didn't work

itaied246 avatar Sep 15 '18 14:09 itaied246

@itaied246 could be a regex problem, see https://github.com/NekR/offline-plugin/issues/51#issuecomment-219582454. Please check if it works for you.

GGAlanSmithee avatar Nov 16 '18 07:11 GGAlanSmithee

I may have had a similar issue when trying to exclude urls for cloud functions that I have configured in firebase. It seems that the excludes option, excludes files if they are present in the build directory and results in them not being added to the hashesMap and assets in sw.js. However because I had the appShell option set to redirect everything to / (as is the default configuration in react-boilerplate), once the service worker is loaded my calls to the cloud functions just resolved to the index. After a while I figured out that I didn't need the appShell option as firebase is configured to send the index for everything it doesn't otherwise know about. So for me the solution so far seems to be to have the following firebase hosting config:

    "rewrites": [
      {
        "source": "/functions/*",
        "function": "functions"
      },
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]

and to remove the appShell option. Using the excludes option does nothing in this case. For your case I think the /__/auth/**/* routes are implied rewrites and won't need to be added to your hosting config, but if you delete the appShell option and ensure you have the index rewrite as in the above firebase hosting config then you may get the behaviour you want.

I just started messing around with react-boilerplate though so I hope this still works with the internal routing (haven't tested that yet, but i don't see why it would be impacted)

pghalliday avatar Nov 26 '18 02:11 pghalliday

I have the same issue of the service working catching the __/auth and not redirecting to Google. Anyone have a solution they could share?

joshuaellis avatar May 30 '19 20:05 joshuaellis

Haven't tested this in Production just something I was able to get working in dev and testing environments

No clue if this is best practices or the root cause. Leaving this here as more of breadcrumbs for anyone hitting something similar.

For some reason my old SW was taking updates, but it appears the "excludes" path didn't work until I removed whatever I had screwed up with the old sw.

new RemoveServiceWorkerPlugin({ filename: 'sw.js' });

new OfflinePlugin({
      relativePaths: false,
      publicPath: '/',
      appShell: '/',

      ServiceWorker: {
        output: 'newsw.js',
        events: true,
        navigateFallbackURL: '/',
      },

      excludes: ['.htaccess', '*/__/auth*/{*.*,.*}'],

After making this change it works properly in both dev and test environments. Content is served from the service worker when expected and the '__/auth' calls are excluded.

mandyMooreFan avatar Oct 02 '19 16:10 mandyMooreFan