Skip to content

Commit

Permalink
Add ApiHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
linxiaoxin committed Sep 16, 2024
1 parent 7206bb7 commit 0012be2
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/ApiHelper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export const ApiHelper = {

getRequestHeaders() {
const headers = new Headers();
headers.append('Content-Type', 'application/json');
if(process.env.NODE_ENV === 'development' && process.env.NEXT_PUBLIC_USERID && process.env.NEXT_PUBLIC_USERID.trim().length > 1){
headers.append('x-user-id', process.env.NEXT_PUBLIC_USERID);
}
if(process.env.NODE_ENV === 'development' && process.env.NEXT_PUBLIC_USEREMAIL && process.env.NEXT_PUBLIC_USEREMAIL.trim().length > 1){
headers.append('x-user-email', process.env.NEXT_PUBLIC_USEREMAIL);
}
return headers;
},
}

export default ApiHelper;

0 comments on commit 0012be2

Please sign in to comment.