File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ This example aims to test the `js-auth` library on Vercel and Netlify edges.
1717### Test link
1818
1919- https://commercelayer-js-auth-nextjs.vercel.app/
20- - https://commercelayer-js-auth-nextjs.vercel.app/middleware
20+ - https://commercelayer-js-auth-nextjs.vercel.app/proxy
2121- https://commercelayer-js-auth-nextjs.vercel.app/api/test
2222
2323## Netlify
@@ -34,5 +34,5 @@ This example aims to test the `js-auth` library on Vercel and Netlify edges.
3434### Test link
3535
3636- https://commercelayer-js-auth-nextjs.netlify.app/
37- - https://commercelayer-js-auth-nextjs.netlify.app/middleware
37+ - https://commercelayer-js-auth-nextjs.netlify.app/proxy
3838- https://commercelayer-js-auth-nextjs.netlify.app/api/test
Original file line number Diff line number Diff line change 1- import Image from "next/image"
1+
22import styles from "./DefaultTemplate.module.css"
33
44export default function DefaultTemplate ( {
@@ -9,23 +9,23 @@ export default function DefaultTemplate({
99 < main className = { styles . main } >
1010 < div className = { styles . description } >
1111 < p > { title } </ p >
12- < a href = '/' > Back to home</ a >
12+ < a href = "/" > Back to home</ a >
1313 </ div >
1414
1515 < div className = { styles . center } > { children } </ div >
1616
1717 < div className = { styles . grid } >
1818 < a
19- href = "/middleware "
19+ href = "/proxy "
2020 className = { styles . card }
2121 target = "_blank"
2222 rel = "noopener noreferrer"
2323 >
2424 < h2 >
25- Middleware < span > -></ span >
25+ Proxy < span > -></ span >
2626 </ h2 >
2727 < p >
28- < code > auth.js</ code > within a middleware .
28+ < code > auth.js</ code > within a proxy .
2929 </ p >
3030 </ a >
3131
Load diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import type { NextProxy } from "next/server"
2+
3+ export type WithProxy = ( next ?: NextProxy ) => NextProxy
Original file line number Diff line number Diff line change @@ -8,16 +8,16 @@ import { NextResponse } from 'next/server'
88import { createStorage } from "unstorage"
99import memoryDriver from "unstorage/drivers/memory"
1010import { makeCustomerStorage } from "@/app/utils/customerStorage"
11- import type { WithMiddleware } from "./types"
11+ import type { WithProxy } from "./types"
1212
1313const clientId = process . env . NEXT_PUBLIC_CLIENT_ID as string
1414const scope = process . env . NEXT_PUBLIC_SCOPE as string
1515
16- export const withCommerceLayer : WithMiddleware = (
16+ export const withCommerceLayer : WithProxy = (
1717 _next = ( ) => NextResponse . next ( ) ,
1818) => {
1919 return async ( request , _event ) => {
20- if ( request . nextUrl . pathname . endsWith ( "/middleware " ) ) {
20+ if ( request . nextUrl . pathname . endsWith ( "/proxy " ) ) {
2121 const auth = await authenticate ( "client_credentials" , {
2222 clientId,
2323 scope,
@@ -30,7 +30,7 @@ export const withCommerceLayer: WithMiddleware = (
3030 }
3131
3232 return NextResponse . json ( {
33- from : "middleware " ,
33+ from : "proxy " ,
3434 orgSlug : decodedJWT . payload . organization . slug ,
3535 baseEndpoint : getCoreApiBaseEndpoint ( auth . accessToken ) ,
3636 } )
Original file line number Diff line number Diff line change 1- import { withCommerceLayer } from './middlewares /withCommerceLayer'
1+ import { withCommerceLayer } from './proxies /withCommerceLayer'
22
33export default withCommerceLayer ( )
44
You can’t perform that action at this time.
0 commit comments