Skip to content
This repository has been archived by the owner on Jul 15, 2020. It is now read-only.

Commit

Permalink
Adding Promise polyfill to Session class for MSIE
Browse files Browse the repository at this point in the history
Internet Explorer and Opera Mini are the only browsers than don't support promises and adding this small polyfill addresses that problem (and fixes #9).

There are other polyfills that are better in scope, but at this point only Internet Explorer needs it this is a simple and compatible solution.

Note: Some Promise related warnings (but not errors) may be still generated in the console in MSIE which using a different polyfill might resolve, but this does not impact the user experience.
  • Loading branch information
iaincollins committed Feb 13, 2017
1 parent 9756474 commit e9ff5e0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions components/session.js
Expand Up @@ -6,6 +6,14 @@
* Service Workers and they cannot share cookies with the browser session
* yet (!) so if we tried to get or pass the CSRF token it would mismatch.
*/
import Promise from 'promise-polyfill'

// Add Promise polyfill if Pomises are not supported natively
// i.e. Internet Explorer and Opera Mini
if (typeof window !== 'undefined' && !window.Promise) {
window.Promise = Promise
}

export default class Session {

constructor({req} = {}) {
Expand Down
3 changes: 2 additions & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "nextjs-starter",
"version": "2.5.13",
"version": "2.5.14",
"description": "A starter Next.js project with email and oAuth authentication",
"author": "Iain Collins <me@iaincollins.com>",
"license": "ISC",
Expand All @@ -23,6 +23,7 @@
"passport-facebook": "^2.1.1",
"passport-google-oauth": "^1.0.0",
"passport-twitter": "^1.0.4",
"promise-polyfill": "^6.0.2",
"raw-loader": "^0.5.1",
"react": "^15.4.2",
"react-redux": "^4.4.6",
Expand Down

0 comments on commit e9ff5e0

Please sign in to comment.