7

I have built an Excel add-in by React+Node+Umi. We have implemented our authentication system. The authentication works in Chrome and Safari, I just realized that it does not work well in IE11; F12 shows that 'Proxy' is undefined.

Although it is an Excel add-in, we could reproduce the error (and the same error message) just in browser. Open the link https://jsaddin.10studio.tech/welcome/?next=formulaEditor in IE 11, sign in with ID 3094557608@qq.com and password: 123456. We could see the error message in F12.

enter image description here

Does anyone know

  1. how to fix this?
  2. how could I know which library/part of my code uses this Proxy? I may replace it by alternatives.

Edit 1: In .umirc.ts:

treeShaking: true,
targets: {
  ie: 9,
  safari: 9,
},

In package.json:

"umi": "^2.7.0",
"umi-plugin-react": "^1.8.0",
"umi-types": "^0.2.0"

Edit 2:

I tried yarn add proxy-polyfill, then yarn start. Curiously, it raised an error in localhost Invalid character and 'umi' is undefined:

enter image description here

SoftTimur
  • 5,630
  • 38
  • 140
  • 292
  • hi, i am also facing same issue, 'Proxy' is undefined. i have added import "@pnp/polyfill-ie11"; but still same issue. Any help please – Sanjeev Gautam May 19 '20 at 09:29

1 Answers1

0

It looks like you are missing a polyfill. Did you check this config for umi.js? https://umijs.org/config/#targets

Setting the target of ie to 11 (as in the above link) should handle adding the polyfills you need.

  targets: {
    ie: 11,
    ...other browsers
  },
  ...rest of the config

LE:

In case there is an issue with umi.js you can try adding the needed polyfills yourself (e.g. here is one for Proxy https://github.com/GoogleChrome/proxy-polyfill)

tudor.gergely
  • 4,800
  • 1
  • 16
  • 22
  • It is currently `ie: 9` in `.umirc.ts`. As it is `Configuring the minimum version of browsers you want to compatible with`, it should be compatible with IE 11, right? – SoftTimur Feb 24 '20 at 09:31
  • @SoftTimur looks like there is an open issue about this in the Github repo of umi.js https://github.com/umijs/umi/issues/3985. I would suggest adding the polyfill yourself until the issue is resolved – tudor.gergely Feb 24 '20 at 14:38
  • Oh, sorry, I didn't know that. Did you try adding the needed polyfill by yourself? – tudor.gergely Feb 24 '20 at 18:11
  • I have not tried yet. I'm still trying to test the project on my local windows. Based on the readme, I should first `Install via your favourite package manager as proxy-polyfill`, then what does `You should include proxy-polyfill into your build system (just require it directly, it doesn't export anything), or import the proxy.min.js file directly. ` mean? – SoftTimur Feb 24 '20 at 18:16
  • you can just do `require('proxy-polyfill')` somewhere at the root of your project (do you have an index.js file where you mount react?), after installing the package (do you use npm?) – tudor.gergely Feb 24 '20 at 18:33
  • Or you can add the proxy.min.js inside node_modules to your html file, before other scripts are included. I'm not exactly sure of your setup, so I cannot say exactly how to include this file, you just need to put it somewhere in your project – tudor.gergely Feb 24 '20 at 18:34
  • @SoftTimur also, I see you are using umi@2.7, can you try upgrading to the latest version? – tudor.gergely Feb 25 '20 at 07:44
  • @SoftTimur any news on this? did you try adding the polyfill yourself? – tudor.gergely Feb 27 '20 at 18:16
  • Thank you for asking, I have not tried yet. I will let you know... – SoftTimur Feb 27 '20 at 18:17
  • Please see my `Edit 2` in OP. – SoftTimur Mar 02 '20 at 01:28
  • I see, does the error happen in other browsers as well or only IE? – tudor.gergely Mar 02 '20 at 15:24
  • can you try setting the target for ie to 11 instead of 9? and for safari to 10? – tudor.gergely Mar 02 '20 at 15:28