Skip to content

Commit

Permalink
Reference hash in router
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanlee85 committed Nov 6, 2024
1 parent 7b3ddef commit c6170cb
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions routes.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
// This file was automatically added by edgio init.
// You should commit this file to source control.
import { Router } from '@edgio/core/router';
import datafileHash from './lib/optimizely/datafile_hash.json';

export default new Router()
// Add a custom route for the Optimizely Edge Function
.match('/', {
edge_function: './edge-functions/main.js',
})
// Invoke the Optimizely Edge Function for new users
.match(
{
cookies: {
[`optimizely_visitor_id_${datafileHash.hash}`]: /^$/,
},
},
{
edge_function: './edge-functions/main.js',
}
)

.match('/:path*/:file.:ext(js|mjs|css)', {
headers: {
Expand Down

0 comments on commit c6170cb

Please sign in to comment.