Edge Functions enable you to execute a small piece of JavaScript code on our edge servers. This code can be used to modify requests and responses as well as make additional calls to your defined origins. The benefits of using Edge Functions include enhancing performance by reducing latency, improving user experience by personalizing content, and increasing security by managing authentication and redirection at the edge. They allow you to execute your code closer to users, reducing the need to go back to the original server and thus, provide faster services.
Key information:
- This article assumes that you are familiar with defining rules using CDN-as-Code or the Edgio Console.
- Edge Functions requires activation. Contact your account manager or our sales department at 1 (866) 200 - 5463 to upgrade your account.
Prerequisites
Setup requires:
- An Edgio account. Sign up for free.
- An Edgio property. Learn how to create a property.
- Node.js. View supported versions and installation steps.
- Edgio CLI.
Edge Functions
Edge functions are standalone JavaScript functions that are executed on the edge servers. They are defined within a JavaScript file and exported as an asynchronous function named
handleHttpRequest
:JavaScript./edge-functions/index.js
1/**2 * Handles an HTTP request and returns a response.3 *4 * @async5 * @param {Request} request - Represents the incoming request.6 * @param {Object} context - Provides additional information about the request and environment.7 * @param {Object} context.client - The client's network information.8 * @param {Object} context.device - The client's device capabilities.9 * @param {Object} context.environmentVars - Environment variables as defined in the Developer Console.10 * @param {Object} context.geo - The client's geo location.11 * @param {Object} context.metrics - Provides functions for injecting metrics into your edge function.12 * @param {Function} context.metrics.add - Adds a value to the metric with the given ID.13 * @param {Function} context.metrics.startTimer - Starts a timer for the metric with the given ID. Only one timer can be active at a time for a given metric ID.14 * @param {Function} context.metrics.stopTimer - Stops a timer for the metric with the given ID.15 * @param {Object} context.origins - Origin servers as defined in the Edgio Console or the edgio.config.js file.16 * @param {Object} context.requestVars - Information about this property including values set using Set Variables.17 * @returns {Response | Promise<Response>}18 */19export async function handleHttpRequest(request, context) {20 // ... function code ...21}
This function is invoked when an incoming request matches a rule that has an edge function assigned to it. Only a single edge function can be assigned to a rule. If multiple rules match an incoming request, the edge function assigned to the last matching rule is invoked.
The location where edge functions are defined depends on the configuration of your property. There are two methods for defining edge functions:
- CDN-as-Code - Define edge functions within your local project codebase.
- Rules UI - Define edge functions within the Edgio Console.
CDN-as-Code
For properties using CDN-as-Code, edge functions are defined within your local project codebase. You can define edge functions by:
-
Storing your standalone JavaScript code as a file with a
js
file extension. -
Setting an
edge_function
property within yourroutes.[js|ts]
. Set this string property to the relative path to your edge function.JavaScript./routes.js1import {Router} from '@edgio/core/router';2export default new Router()3 .get('/', {4 edge_function: './edge-functions/index.js',5 })6 .match('/api/*', {7 edge_function: './edge-functions/api.js',8 });
Rules (Edgio Console)
For properties managed within the Edgio Console, edge functions are defined at the environment level. Navigate to your property and perform the following steps:
- Identify the environment (e.g.,
production
) that will contain the edge function. - Click on Edge Functions in the left-hand navigation and choose the Code tab.
- Click on Add Function and provide a name for the edge function file.
- Once the file is created, you can define your edge function logic within the editor.
- Apply the edge function to your rule(s) by choosing the Edge Function feature and selecting the edge function you created.
Edge Function Initialization Script (Optional)
This edge function feature is only compatible with CDN-as-Code deployments.
An edge function initialization script is a JavaScript file executed once before any edge function in a project is invoked. This script is particularly beneficial for projects with two or more edge functions, allowing for the setup of global variables, initialization of third-party libraries, and defining utility functions used across multiple edge functions. It reduces duplicate code setup and is specified within the
routes.[js|ts]
file. The script must adhere to specific execution and memory constraints, similar to the edge functions themselves.To specify an edge function initialization script, add the
edge_function_init_script
property to the Router(...)
constructor. The edge_function_init_script
property accepts a string representing the path to the script.JavaScript./routes.js
1import {Router} from '@edgio/core/router';23export default new Router({4 // Specify an edge function initialization script5 edge_function_init_script: './edge-functions/init.js',6}).get('/', {7 edge_function: './edge-functions/main.js',8});
The initialization script must export the following entry point:
JavaScript./edge-functions/init.js
1/**2 * @async3 * @param {Object} context - Provides additional information about the request and environment.4 * @returns {void}5 */6export async function handleHttpInit(context) {7 // ... function code ...8}
Key information:
-
Execution Context: It’s important to note that certain parts of the
context
, likegeo
,client
, anddevice
, may not be relevant or populated during initialization as they are request-specific. The most relevant part of the context for initialization iscontext.environmentVars
. -
Execution Frequency and State Preservation: The initialization code runs upon the first request received for any edge function within the project/bundle. After execution, the state is saved as a memory snapshot for subsequent executions of the project’s edge functions. These snapshots are specific to each backend cache server and will be periodically evicted based on internal criteria. Upon eviction,
handleHttpInit
will execute again for the next request. -
CPU/Memory Limitations: The initialization script shares the same CPU and memory limitations as the edge functions. This includes the execution time constraint (i.e., 50ms).
-
Use Cases: An initialization script is ideal for computationally expensive operations like compiling regex, which is beneficial to perform once rather than in every edge function execution. However, operations like fetch are not recommended in this phase due to potential persistence of fetched data beyond desired periods.
-
Consideration for Global State: Developers should be cautious when using the
context
to set up specific code or save data in theglobal
scope during initialization, as it may persist and potentially lead to incorrect behavior across different requests.
The following sample code demonstrates how to set up a global variable within an edge function initialization script and access it within an edge function.
JavaScript./edge-functions/init.js
1export async function handleHttpInit(context) {2 // Set up a global regular expression for matching URLs3 global.urlRegex = new RegExp('https://example.com');4}
JavaScript./edge-functions/main.js
1export async function handleHttpRequest(request, context) {2 // Access the global variable3 if (global.urlRegex.test(request.url)) {4 // ... function code ...5 }6}
Edge Function Parameters
The edge function is passed two parameters:
request
and context
.request
is an object representing the incoming request and context
is a read-only object providing additional information about the request and your environment, such as access to the client’s network information, device capabilities, geo location, environment variables, origin servers, and information about this property including values set using variables. It also provides functions for injecting metrics into your edge function and for returning the response from your edge function to the downstream client.Parameter | Type | Description | Reference |
---|---|---|---|
request | Object | Represents the incoming request | Request |
context | Object | A read-only object providing additional information about the request and your environment | |
context.client | Key-value store | The client’s network information | virt_ variables in Feature Variables |
context.device | Key-value store | The client’s device capabilities | wurfl_ variables in Feature Variables |
context.environmentVars | Key-value store | Environment variables as defined in the Edgio Console (Property -> Environment —> Environment Variables) | Environment Variables |
context.geo | Key-value store | The client’s geo location | geo_ variables in Feature Variables |
context.metrics | Object | Provides functions for injecting metrics into your edge function | Edge Insights - Access Logs |
context.origins | Key-value store | Origin servers as defined in the Edgio Console (Property -> Environment -> Origins) or the edgio.config.js file | Origin Configuration |
context.requestVars | Key-value store | Information about this property including values set using Set Variables | Set Variables |
context.respondWith(response) | Function |
| context.respondWith(response) |
context.waitUntil(promise) | Function | Waits until the given promise is fulfilled | context.waitUntil(promise) |
Metrics Functions
Inject up to 10 metrics into your edge function through
context.metrics
. Metric data is reported through Edge Insights when viewing log data for the Access Logs data source. View these metrics by clicking on an entry within the Logs section and then looking for Edge Function Customer Metric #
log fields.Function | Description |
---|---|
context.metrics.add(id: integer, value: integer) | Adds a value to the metric with the given ID. Valid values for id are 0 - 9 . |
context.metrics.startTimer(id: integer) | Starts a metric’s timer. Only a single timer can be active at any time for a given ID. |
context.metrics.stopTimer(id: integer) | Stops a metric’s timer. |
Edge Function Namespace
Edge Functions global namespace provide access to the following:
Global Object/Class | Description | Reference |
---|---|---|
console object | The standard console object used to log messages to the console. | Console Object |
Headers Class | The standard Headers class used to manipulate headers on requests and responses. | Headers Class |
Request Class | The standard Request class used access the initial request on this route and to make new requests to the origin server. | Request Class |
Response Class | The standard Response class used to access responses from the origin server and to create new downstream responses | Response Class |
fetch(request) | A modified fetch() function used to makes requests to the origin server. | Fetch API |
TextDecoder | Polyfill class to manage decoding text. | TextDecoder |
TextEncoder | Polyfill class to manage encoding text. | TextEncoder |
URL | Polyfill class to manage URLs. | URL |
URLSearchParams | Polyfill class to manage URL search parameters. | URLSearchParams |
parseURL | Function to parse URLs. | parseURL |
Request Class
Edge functions use a modified version of the standard
Request
API. See the Unsupported Methods and Properties section for more information.Edge functions are passed a
Request
instance representing the incoming request. This object provides methods and properties for accessing the request’s headers, body, URL, and more.Supported Methods and Properties
- Headers: Access the request headers using
request.headers
. - Body: The request body can be read as:
- ArrayBuffer:
await request.arrayBuffer()
- JSON:
await request.json()
- Text:
await request.text()
- ArrayBuffer:
- Method:
request.method
to get the HTTP method of the request. - URL:
request.url
: Provides the full URL.request.path
: Provides the request path.request.originalUrl
: Requires Edgio version 7.13.6 or later. Provides the original URL sent by the user agent. This property is only present on the incoming request provided to thehandleHttpRequest
handler.
As of Edgio version 7.13.6, therequest.path
andrequest.url
properties return the rewritten path or URL, respectively. - Cloning: To clone a request without its body, use
request.cloneWithoutBody()
.
Unsupported Methods and Properties
The following properties and methods from the standard
Request
API are not supported:request.blob()
request.cache
request.credentials
request.clone()
request.destination
request.formData()
request.integrity
request.mode
request.redirect
request.referrer
request.referrerPolicy
request.signal
Using an unsupported method or property will throw an error.
Response Class
Edge functions use a modified version of the standard
Response
API. See the Unsupported Methods and Properties section for more information.Origin fetch requests and edge functions return a
Response
instance representing the response. This object provides methods and properties for accessing and setting the response’s headers, body, status code, and more. Create a response through the Response
class or by calling the fetch()
function. See the Edge Function Namespace section for more information.Supported Methods and Properties
-
Headers: Access or modify the response headers using
response.headers
. -
Body: The response body can be interacted with using:
- ArrayBuffer:
await response.arrayBuffer()
- JSON:
await response.json()
- Text:
await response.text()
- ArrayBuffer:
-
Status:
response.status
to get the HTTP status code of the response.response.statusText
provides the corresponding status text. -
URL:
response.url
provides the URL of the response. -
Redirected:
response.redirected
is a property that indicates whether the response is a result of a redirection.You may redirect a response up to 5 times before an exception is thrown. -
Redirection: Create a redirected response using
Response.redirect(url, status)
. -
Cloning: To clone a response without its body, use
response.cloneWithoutBody()
.
Unsupported Methods and Properties
The following properties and methods from the standard
Response
API are not supported:response.blob()
response.clone()
response.formData()
response.type
Note: The above-mentioned unsupported methods and properties will throw an error if attempted to be used.
Responding to the Client
Edge functions must respond to the client by returning a
Response
object or a Promise
that resolves to a Response
object. The Response
object can be created using the Response
class or by calling the fetch()
function. See the Edge Function Namespace section for more information.JavaScript./edge-functions/example.js
1export async function handleHttpRequest(request, context) {2 const defaultResponse = new Response('Hello World!');3 const response = await fetch('https://your-server.com', {4 edgio: {5 // an origin name must be specified in the request6 origin: 'web',7 },8 });910 if (!response.ok) {11 return defaultResponse;12 }1314 return response;15}
As of v7.2.3, the
context.respondWith()
function is deprecated. You must return a Response
object or a Promise
that resolves to a Response
object to respond to the client.Origin Requests Using fetch()
Before issuing a fetch request to an origin, you must define an origin configuration within the
edgio.config.js
file or the Edgio Console. The origin configuration specifies the origin server to which the request is sent. See Origin Configurations for more information.Request a resource from an origin by passing two required arguments to the
fetch()
function. Set the first argument to a URL or a Request
object. Set the second argument to the name of the origin and any additional options compatible with the fetch()
function.JavaScript./edge-functions/example.js
1export async function handleHttpRequest(request, context) {2 const resp = await fetch('https://your-server.com', {3 // an Edgio origin must be specified in the request4 edgio: {5 origin: 'web',6 },7 });89 // handle the response as needed10 /* ... */1112 // return the response to the client13 return resp;14}
Create a reusable
fetch()
function by defining a utility function such as createFetchForOrigin()
. See the Polyfills and Helpers section for more information.JavaScript./edge-functions/example.js
1export async function handleHttpRequest(request, context) {2 const fetch = createFetchForOrigin('web');34 const resp = await fetch('https://your-server.com');56 // handle the response as needed7 /* ... */89 // return the response to the client10 return resp;11}
Some libraries allow you to specify a
fetch()
function to use. For example, PlanetScale’s database driver configuration accepts a custom function to use when making requests to the API.You may only deploy this edge function using CDN-as-Code due to Node.js dependencies. It will not work when deployed through the Edgio Console.
JavaScript./edge-functions/example.js
1import {connect} from '@planetscale/database';23// Custom fetch function. See Polyfills and Helpers section for more information.4import {createFetchForOrigin} from './polyfills';56const fetch = createFetchForOrigin('planetscale');78export async function handleHttpRequest(request, context) {9 const env = context.environmentVars;1011 const config = {12 host: env.PLANETSCALE_HOST,13 username: env.PLANETSCALE_USERNAME,14 password: env.PLANETSCALE_PASSWORD,15 fetch,16 };1718 const conn = connect(config);1920 // make a request to the PlanetScale API21 /* ... */2223 // return the response to the client24 return resp;25}
This approach allows for creating unique
fetch()
functions for each origin server. Optionally, you can override the global fetch()
function if you are unable to specify a fetch()
function in your library.JavaScript./edge-functions/example.js
1// Custom fetch function. See Polyfills and Helpers section for more information.2import createFetchForOrigin from './polyfills';34export async function handleHttpRequest(request, context) {5 const fetch = createFetchForOrigin('api');67 // override the global fetch() function8 global.fetch = fetch;910 // make a request to the your API11 /* ... */1213 // return the response to the client14 return resp;15}
edgio_self Origin
The origin
edgio_self
is a system-defined origin, referencing the current environment, used to fetch resources from the same property. This origin is particularly useful for composing complex behaviors where different resources within the same property need to interact with each other. When making a fetch request to the edgio_self
origin, the request undergoes the same processing steps as an incoming request from the client, including the application of rules and transformations specific to the requested path.Consider the following scenario where an incoming request is made to
/products
, which is handled by an edge function to fetch another resource /promotions
on the same environment:JavaScriptroutes.js
1import {Router} from '@edgio/core/router';23export default new Router()4 // Incoming requests for `/products` are handled by an edge function5 .get('/products', {6 edge_function: './edge-functions/products.js',7 })89 // Incoming requests for `/promotions` are proxied to the origin server10 .get('/promotions', {11 origin: {12 set_origin: 'web',13 },14 });
JavaScript./edge-functions/products.js
1export async function handleHttpRequest(request, context) {2 // Fetch the promotions resource from the same property3 const promosUrl = new URL('/promotions', request.url);4 const resp = await fetch(promosUrl, {5 edgio: {6 origin: 'edgio_self',7 },8 });910 // handle the response as needed (e.g., apply sale promotions to products)11 /* ... */1213 // return the response to the client14 return resp;15}
-
Incoming Request for
/products
:- The incoming request matches the
/products
route and is handled by the edge function. - The edge function is invoked, which is configured to fetch another resource
/promotions
on the same property.
- The incoming request matches the
-
Internal Fetch to
/promotions
:- The edge function makes an internal fetch to
/promotions
as instructed by theedgio_self
origin. - The incoming request for
/promotions
is processed by the corresponding route. - Applicable incoming request rules are applied.
- The request is then forwarded to the origin server.
- The origin server processes the request and returns a response.
- Applicable response rules for
/promotions
are applied. - The response is then sent back to the edge function.
- The edge function makes an internal fetch to
-
Returning the Final Response:
- The edge function receives the response for
/promotions
. - It may further process this response and then generates its own response.
- Applicable response rules for
/products
are applied. - Finally, the response for
/products
is sent back to the client.
- The edge function receives the response for
Key Points
- The
edgio_self
origin instructs edge functions to send fetch requests to itself. - This capability is particularly useful for composing complex behaviors where different resources within the same property need to interact with each other.
- It ensures that each request, whether it’s an initial browser request or an internally generated fetch from an edge function, undergoes the appropriate set of rules and processing steps configured for its specific path.
Caching fetch() Requests
See the Edge Function Caching guide for more information on caching origin fetch requests.
Compressed Responses
Edge functions do not automatically decompress responses from the origin server, specifically when those responses are encoded with compression methods like
gzip
or br
. This characteristic becomes relevant if you need to manipulate the response body before sending it to the client, as decompression would be a necessary step in processing the data. Responses that are merely passed through from the origin to the client without modification are not impacted by this behavior.If your edge function manipulates the response body of a fetch request, we recommend that you disable compression by setting the
Accept-Encoding
request header. This ensures the response from the origin is not compressed, making it directly accessible for manipulation. The following sample code demonstrates how to disable compression on a fetch request:JavaScript./edge-functions/example.js
1async function handleRequest(request) {2 // Modify the request to disallow compressed responses3 const modifiedRequest = new Request(request, {4 headers: new Headers({5 ...request.headers,6 'Accept-Encoding': 'identity', // Disallow compression methods like gzip or br7 }),8 });910 // Fetch the response from the origin server11 const response = await fetch(modifiedRequest);1213 // Assuming the response needs to be manipulated14 let responseBody = await response.text(); // Get the response body as text15 responseBody = responseBody.replace('foo', 'bar'); // Manipulate the response body1617 // Return the manipulated response to the client18 return new Response(responseBody, response);19}
Fetch Limitations
Response status codes of
fetch()
requests must:- Be greater than or equal to 200.
- Be less than or equal to 599.
- Not be 204 or 304.
If the response status code does not meet these criteria, the edge function will throw an error. It may be necessary to remove specific cache directives from the request before sending it to the origin.
The following sample code strips the cache directive headers from the request before sending it to the origin:
JavaScript./edge-functions/example.js
1export async function handleHttpRequest(request) {2 /* ... */34 // Remove headers that could cause the a response status of 204/304 to be returned.5 const headersToRemove = [6 'etag',7 'if-modified-since',8 'if-none-match',9 'last-modified',10 ];11 headersToRemove.forEach((header) => request.headers.delete(header));1213 const response = await fetch(request.url, {14 edgio: {15 origin: 'web',16 },17 method: request.method,18 headers: request.headers,19 });2021 // handle the response as needed2223 return response;24}
Testing Locally
You may run Edgio in local development mode to preview your website on your local machine prior to deployment. Local development mode allows for rapid development by letting you to quickly test changes prior to deployment.
- From the command line or terminal, type
edgio dev
. - Preview your website by loading
https://127.0.0.1:3000
from within your preferred web browser.
Note that edge functions executed in local development mode are simulated and may not reflect the behavior or performance of deployed edge functions.
Deploying Your Property
Evaluate site performance and QA functionality by deploying your property to Edgio. Run the following command from your property’s root directory:
Bash
1edgio deploy
Note that Edge Functions must be enabled for your Edgio Console team in order to deploy your property. Contact support to enable this feature.
Limitations of Edge Functions
Edge functions are only compatible with edge links. Permalinks are unsupported since they bypass the edge network and serve content directly from the origin. This behavior causes either degraded functionality or prevents edge function logic from being applied.
When deploying your project, it’s important to distinguish between the edge link and the permalink for proper testing and functionality verification. The following screenshot indicates where you can find the permalink and edge link for your project in the Edgio Console.
Edge Function limitations:
Metric | Limit |
---|---|
Wall Clock Time | 60 seconds |
Execution Time | 50 milliseconds |
Memory | 4 MB |
Code Package Size | 512 KB |
The code package size refers to the compiled JavaScript bytecode. All edge functions are bundled into a single package for deployment to our edge servers. If the total compiled size exceeds 512KB, the deployment will fail and return a 400 error:
plaintext
12023-08-14T17:37:04Z - error - external - Schema validation error: properties.0.edge_functions.quickjs_bytecode_base64 exceeds maximum size. Max: 512000, got: 151446922023-08-14T17:37:04Z - error - external - Error: the server responded with status 400
Runtime memory encompasses all variables, HTTP requests and responses, as well as the context object. This total must not exceed 4MB.
Edge functions are confined to 50ms of CPU time and a maximum of 60s for overall execution. Time spent waiting for a response from an origin server is not counted against the 50ms CPU time limit.
Polyfills and Helpers
It’s important to note that edge functions are not Node.js functions. Your code or third-party libraries may not work as expected if they are referencing Node.js specific APIs (e.g.
Buffer
, process
, etc). Because of this, we recommend using polyfills when needed. Below are some examples of polyfills you can use in your edge functions.-
Buffer
APIJavaScript1// 'buffer' polyfill is provided by the Edgio CLI2global.Buffer = require('buffer').Buffer;34global.btoa = function (str) {5 return Buffer.from(str, 'binary').toString('base64');6};78global.atob = function (b64Encoded) {9 return Buffer.from(b64Encoded, 'base64').toString('binary');10}; -
process.env
NamespaceThis namespace is not globally available in edge functions. You can define the following polyfill to set environment variables from the context object.JavaScript1/**2 * Define a polyfill for 'process'3 */4global.process = global.process || {env: {}};56/**7 * Sets environment variables from a given context.8 *9 * @param {Object} context - The context object containing environment variables.10 * @param {Object} context.environmentVars - Key-value pairs of environment variables.11 */12export function setEnvFromContext({environmentVars}) {13 Object.assign(process.env, environmentVars);14} -
URL
ClassThis class, provided by the Edgio CLI, is compatible with the standard URL class.JavaScript1let url = new URL('https://www.url.com/path');2url.port = 8080;3let newUrl = url.toString(); // newUrl will equal 'https://www.url.com:8080/path'JavaScript1let url = new URL('/patha/pathb', 'https://www.url.com/');2let newUrl = url.toString(); // newUrl will equal 'https://www.url.com/patha/pathb' -
URLSearchParams
ClassThis class, provided by the Edgio CLI, is compatible with the standard URLSearchParams class.JavaScript1let url = new URL('https://www.url.com/path?a=b');2let params = url.searchParams;3params.set('c', 'one');4let newUrl = url.toString(); // newUrl will equal 'https://www.url.com/path?a=b&c=one'
Polyfill Limitations
It’s worth noting that not all implementations will be able to accept polyfills, either due to the number of dependencies affected or the compiled size of the polyfill exceeding the Limitations of Edge Functions.
Helper Functions
-
This function returns a modified
fetch()
function that includes the origin server. This is useful for making multiple requests to the same origin or overriding the global function.Some third-party libraries let you specify afetch()
function. If you are unable to set this in your library, you can override the global one using this helper. See the Origin Requests Using fetch() section for more details.JavaScript1/**2 * Creates a fetch function with an additional 'edgio' option to specify the origin. Example usage:3 *4 * // create a fetch function for the 'web' origin.5 * const fetch = createFetchForOrigin('web');6 * const response = await fetch('https://your-server.com');7 *8 * // override the global fetch() function9 * global.fetch = createFetchForOrigin('web');;10 *11 * @param {string} originName - The origin name defined in edgio.config.js.12 * @returns {function} - A modified fetch function.13 * @throws {Error} If the origin name is not provided.14 */15export default function createFetchForOrigin(originName) {16 if (!originName) {17 throw new Error(18 "'originName' is required and must be a name defined in edgio.config.js"19 );20 }2122 return (url, options = {}) => {23 const modifiedOptions = {24 ...options,25 edgio: {26 origin: originName,27 },28 };29 return fetch(url, modifiedOptions);30 };31} -
This function parses a URL string and returns an object containing the URL’s components.JavaScript1// Show all the possible values2parseURL('http://user:password@www.url.com:8080/one/two?a=b#hash')3{4 fragment: 'hash',5 host: 'www.url.com',6 password: 'password',7 path: [ 'one', 'two' ],8 port: 8080,9 query: 'a=b',10 scheme: 'http',11 username: 'user'12}1314// Show the minimum required values15parseURL('https://url.com/')16{17 fragment: null,18 host: 'url.com',19 password: '',20 path: [ '' ],21 port: null,22 query: null,23 scheme: 'https',24 username: ''25}2627// Returns null on empty string or string with bad url28parseURL('url.com')29null3031// Throws on non-string argument32parseURL() // will throw
Edge Function Examples
The following site contains links to multiple examples showcasing Edge Functions.