-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use https_proxy environment variable in next/font/google (#46822)
When fetching CSS or font files from Google Fonts, it won't work if you're required to use a proxy. This change makes it look for the `http(s)_proxy` environment variable, and if it's defined it creates a fetch agent using [https-proxy-agent](https://github.com/TooTallNate/node-https-proxy-agent). Also fixes fetch errors not being properly logged. Fixes #45034 Closes NEXT-690 ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] [e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm build && pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
- Loading branch information
1 parent
f99ae5a
commit 02eb34d
Showing
14 changed files
with
243 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// @ts-ignore | ||
import HttpsProxyAgent from 'next/dist/compiled/https-proxy-agent' | ||
// @ts-ignore | ||
import HttpProxyAgent from 'next/dist/compiled/http-proxy-agent' | ||
import { Agent } from 'https' | ||
|
||
/** | ||
* If the http(s)_proxy environment variables is set, return a proxy agent. | ||
*/ | ||
export function getProxyAgent(): Agent | undefined { | ||
const httpsProxy = process.env['https_proxy'] || process.env['HTTPS_PROXY'] | ||
if (httpsProxy) { | ||
return new HttpsProxyAgent(httpsProxy) | ||
} | ||
|
||
const httpProxy = process.env['http_proxy'] || process.env['HTTP_PROXY'] | ||
if (httpProxy) { | ||
return new HttpProxyAgent(httpProxy) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"name":"http-proxy-agent","main":"index.js","author":"Nathan Rajlich <[email protected]> (http://n8.io/)","license":"MIT"} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"name":"https-proxy-agent","main":"index.js","author":"Nathan Rajlich <[email protected]> (http://n8.io/)","license":"MIT"} |
Oops, something went wrong.