-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(SLB-394): partial port of proxy and edge functions
- Loading branch information
1 parent
a28193a
commit c1f3563
Showing
9 changed files
with
673 additions
and
115 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,6 @@ | ||
export const onRequest: PagesFunction = async (context) => { | ||
const drupalExternalUrl = | ||
// @ts-ignore | ||
context.env.DRUPAL_EXTERNAL_URL || 'http://localhost:8888'; | ||
return fetch(`${drupalExternalUrl}${context.functionPath}`, context.request); | ||
}; |
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,15 @@ | ||
export const onRequestGet: PagesFunction = async (context) => { | ||
const availableLanguages = ['en', 'fr']; | ||
const defaultLanguage = 'en'; | ||
const currentLanguage = context.request.headers | ||
.get('accept-language') | ||
?.substring(0, 2); | ||
let preferredLanguage = defaultLanguage; | ||
if (currentLanguage && availableLanguages.includes(currentLanguage)) { | ||
preferredLanguage = currentLanguage; | ||
} | ||
const statusCode = 302; | ||
const url = new URL(context.request.url); | ||
url.pathname = `/${preferredLanguage}/`; | ||
return Response.redirect(url.toString(), statusCode); | ||
}; |
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,6 @@ | ||
export const onRequestGet: PagesFunction = async (context) => { | ||
const drupalExternalUrl = | ||
// @ts-ignore | ||
context.env.DRUPAL_EXTERNAL_URL || 'http://localhost:8888'; | ||
return fetch(`${drupalExternalUrl}${context.functionPath}`, context.request); | ||
}; |
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
Oops, something went wrong.