-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
84235b4
commit dba2ad1
Showing
8 changed files
with
25,811 additions
and
0 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
examples/v7-image-optimization/.github/pull_request_template.md
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,5 @@ | ||
**NOTICE TO CONTRIBUTORS** | ||
|
||
This repository is not actively monitored and any pull requests made to this repository will be closed/ignored. | ||
|
||
Please submit the pull request to [edgio-docs/edgio-examples](https://github.com/edgio-docs/edgio-examples) instead. |
18 changes: 18 additions & 0 deletions
18
examples/v7-image-optimization/.github/workflows/edgio.yml
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,18 @@ | ||
name: Deploy to Edgio | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
|
||
jobs: | ||
deploy-to-edgio: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
- run: if [ -f yarn.lock ]; then yarn install; else npm ci; fi | ||
- run: if [ -f yarn.lock ]; then yarn edgio:deploy -- --token=$EDGIO_DEPLOY_TOKEN; else npm run edgio:deploy -- --token=$EDGIO_DEPLOY_TOKEN; fi | ||
env: | ||
EDGIO_DEPLOY_TOKEN: ${{secrets.EDGIO_DEPLOY_TOKEN}} |
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,4 @@ | ||
# Edgio generated build directory | ||
/.edgio | ||
|
||
/node_modules |
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,28 @@ | ||
/** | ||
* An example edge function which forwards the request to the origin. | ||
* See routes.js for how this function is configured to run for requests to "/". | ||
*/ | ||
export async function handleHttpRequest(request) { | ||
const resp = await fetch(`https://test-origin.edgio.net${request.path}`, { | ||
edgio: { | ||
origin: 'origin', // this corresponds to the name of the origin in edgio.config.js | ||
}, | ||
}) | ||
|
||
// handle the response as needed | ||
// For example, to inject some html into the body: | ||
const html = await resp.text() | ||
const newHtml = html.replace('</body>', '<marquee>Added by edge functions!</marquee></body>') | ||
|
||
// To send the response to the client with the new HTML but the same headers as the origin response: | ||
return new Response(newHtml, { | ||
...resp, | ||
headers: { | ||
...resp.headers, | ||
'x-edge-function': 'main.js', | ||
}, | ||
}) | ||
|
||
// Or you can just return the original response to the client | ||
// return resp | ||
} |
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,38 @@ | ||
// This file was automatically added by edgio init. | ||
// You should commit this file to source control. | ||
// Learn more about this file at https://docs.edg.io/guides/edgio_config | ||
module.exports = { | ||
// The name of the site in Edgio to which this app should be deployed. | ||
name: 'edgio-v7-image-optimization-example', | ||
|
||
origins: [ | ||
{ | ||
name: 'origin', | ||
override_host_header: 'en.wikipedia.org', | ||
hosts: [ | ||
{ | ||
location: 'en.wikipedia.org', | ||
}, | ||
], | ||
tls_verify: { | ||
use_sni: true, | ||
allow_self_signed_certs: true, | ||
sni_hint_and_strict_san_check: 'en.wikipedia.org', | ||
}, | ||
}, | ||
{ | ||
name: 'upload', | ||
override_host_header: 'upload.wikimedia.org', | ||
hosts: [ | ||
{ | ||
location: 'upload.wikimedia.org', | ||
}, | ||
], | ||
tls_verify: { | ||
use_sni: true, | ||
allow_self_signed_certs: true, | ||
sni_hint_and_strict_san_check: 'upload.wikimedia.org', | ||
}, | ||
}, | ||
], | ||
}; |
Oops, something went wrong.