Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

SWs redirect user to /auth on refresh in production #49

Closed
1 of 2 tasks
ghost opened this issue Aug 6, 2017 · 7 comments
Closed
1 of 2 tasks

SWs redirect user to /auth on refresh in production #49

ghost opened this issue Aug 6, 2017 · 7 comments
Assignees
Labels

Comments

@ghost
Copy link

ghost commented Aug 6, 2017

I'm submitting a ...

  • bug report
  • feature request

Bug Report:

Refreshing page on dashboard cycles through auth

  • Steps to reproduce:

git clone, npm install, npm run build, npm run start

@ghost ghost changed the title Refreshing page on dashboard cycles through auth Refreshing page on dashboard cycles through auth SSR Aug 6, 2017
@ghost
Copy link
Author

ghost commented Aug 6, 2017

After integrating my own API server, all refreshes lead to auth page. SSR only, which is weird. I'm guessing I need to call my own api server inside of the express server or implement a similar endpoint?

@Metnew
Copy link
Owner

Metnew commented Aug 6, 2017

@TheDolo, I found the probable error reason, it's because of auth middleware on the server. Something goes wrong with this middleware + cookies + SSR. Will be fixed as soon as possible, I agree it's a critical bug.

@ghost
Copy link
Author

ghost commented Aug 6, 2017

P.S I found I needed a shift refresh between SSR builds, else even a new tab would load the old build. I'd be in dev mode then build, and find the build was the older one. It's caught me off guard many times heh. TY!!

@Metnew Metnew self-assigned this Aug 6, 2017
@Metnew
Copy link
Owner

Metnew commented Aug 6, 2017

@TheDolo I found the reason of this error. It was caused by invalid property name inside SSR's preloadedState. Server renders {me:{auth:{isLoggedIn:true}}}, but reducers work with loggedIn property.

UPD: it's not the only bug :(

@Metnew Metnew mentioned this issue Aug 8, 2017
2 tasks
@Metnew Metnew added the bug label Aug 8, 2017
@Metnew
Copy link
Owner

Metnew commented Aug 8, 2017

@TheDolo It seems like the issue is caused by SWs fallBackURL, I disable OfflinePlugin and it works perfectly. Try to check this deployment of app. Probably, when a user requests app '/' path, server doesn't handle this because the request is handled by ServiceWorkers.

UPD: OfflinePlugin is required additional configuration, if you want to patch your app - disable Offline plugin or replace current OfflinePlugin config in /webpack_config/client/webpack.prod.babel.js with:

new OfflinePlugin({
	publicPath: '/',
	caches: {
		main: [
			'vendor.*.js',
			'vendor.*.css',
			'manifest.*.js',
			'client.*.js'
		]
	},
	excludes: ['/', ''],
	externals: ['/auth'],
	rewrites: () => {
		return ''
	},
	ServiceWorker: {
	  navigateFallbackURL: '/auth',
          navigateFallbackForRedirects: false
	},
	AppCache: false
})

Optimized patch will be soon.

@Metnew Metnew changed the title Refreshing page on dashboard cycles through auth SSR SWs redirect user to /auth on refresh in production Aug 8, 2017
@Metnew
Copy link
Owner

Metnew commented Aug 8, 2017

#56 includes patch for this issue

@ghost
Copy link
Author

ghost commented Aug 12, 2017

Fixed for me! Thank you.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant