hupe1980 / gatsby-theme-material-ui

Gatsby theme for Material-UI
MIT License
100 stars 42 forks source link

unable to access a google webfonts via authenticate proxy #22

Closed souchi closed 4 years ago

souchi commented 4 years ago

Apparently we unable to access a google webfonts via our authenticate proxy. An error occurs when running "npm run build". Is there a workaround?

cd examples/simple
npm install
...
npm run build
> example-simple@1.0.25 build C:\Users\user01\apps\work\gatsby-theme-material-ui\examples\simple
> gatsby build

success open and validate gatsby-configs - 0.074s
success load plugins - 0.423s
success onPreInit - 0.037s
success delete html and css files from previous builds - 0.048s
success initialize cache - 0.027s
success copy gatsby files - 0.573s

 ERROR #11321  PLUGIN

"gatsby-plugin-webfonts" threw an error while running the onPreBootstrap lifecycle:

connect ETIMEDOUT 172.217.31.138:443

  Error: connect ETIMEDOUT 172.217.31.138:443

not finished onPreBootstrap - 21.518s
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! example-simple@1.0.25 build: `gatsby build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the example-simple@1.0.25 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\user01\AppData\Roaming\npm-cache\_logs\2020-01-31T09_16_20_242Z-debug.log

After setting the HTTPS_PROXY environment variable as follows, occured the status code 503.

$env:HTTPS_PROXY="http://username:password@proxy.mycompany.intra:8080"

npm run build

> example-simple@1.0.25 build C:\Users\user01\apps\work\gatsby-theme-material-ui\examples\simple
> gatsby build

success open and validate gatsby-configs - 0.051s
success load plugins - 0.308s
success onPreInit - 0.024s
success delete html and css files from previous builds - 0.021s
success initialize cache - 0.025s
success copy gatsby files - 0.233s

 ERROR #11321  PLUGIN

"gatsby-plugin-webfonts" threw an error while running the onPreBootstrap lifecycle:

Request failed with status code 503

  Error: Request failed with status code 503

  - createError.js:16 createError
    [simple]/[axios]/lib/core/createError.js:16:15

  - settle.js:17 settle
    [simple]/[axios]/lib/core/settle.js:17:12

  - http.js:236 IncomingMessage.handleStreamEnd
    [simple]/[axios]/lib/adapters/http.js:236:11

  - task_queues.js:81 processTicksAndRejections
    internal/process/task_queues.js:81:21

not finished onPreBootstrap - 0.317s
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! example-simple@1.0.25 build: `gatsby build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the example-simple@1.0.25 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\user01\AppData\Roaming\npm-cache\_logs\2020-01-31T09_22_23_965Z-debug.log

The "npm config list" is as follows.

npm config list
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.13.4 node/v12.14.1 win32 x64"

; userconfig C:\Users\user01\.npmrc
http-proxy = "http://username:password@proxy.mycompany.intra:8080"
https-proxy = "http://username:password@proxy.mycompany.intra:8080"
proxy = "http://username:password@proxy.mycompany.intra:8080"
strict-ssl = false

; node bin location = C:\Program Files\nodejs\node.exe
; cwd = C:\Users\user01\apps\work\gatsby-theme-material-ui\examples\simple
; HOME = C:\Users\user01
; "npm config ls -l" to show all defaults.

I,m using OS:Windows10 Professional node:v12.14.1 npm:6.13.4

Thank you.

hupe1980 commented 4 years ago

The gatsby-plugin-webfonts uses axios to load the google fonts. You can deactivate the plugin and take care of the font yourself. See #16 and add:

<link href="https://fonts.googleapis.com/css?family=Roboto:400,500,700&display=swap" rel="stylesheet"/>

Otherwise we have to enable the plugin to deal with proxies. A PR is welcome 😉

souchi commented 4 years ago

Thank you for the speedy reply.
This issue has been resolved thanks to you.

A PR is a little difficult for me.:sweat_smile:

souchi commented 4 years ago

I solved this issue in another way. I used global-agent.

https://github.com/gajus/global-agent

Thank you.