Skip to content

Commit

Permalink
Merge pull request #80 from middlewarehq/feat/timezone-in-req-headers
Browse files Browse the repository at this point in the history
feat:timezone in req headers
  • Loading branch information
shivam-bit authored Dec 11, 2023
2 parents 18f6b0a + d0578a9 commit 60a64af
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ next-env.d.ts

# Sentry Config File
.sentryclirc

/unwrapped-cards
2 changes: 1 addition & 1 deletion src/pages/api/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const fetchAndDownloadImageBuffer = async (
res: NextApiResponse
) => {
let token = req.cookies.ghct;
const timezone = (req.headers.timezone as string) || 'UTC';
const timezone = (req.headers['x-timezone'] as string) || 'UTC';

if (!token) {
return res.status(403).json({
Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/github/unwrapped.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default async function handler(
res: NextApiResponse
) {
let token = req.cookies.ghct;
const timezone = (req.headers.timezone as string) || 'UTC';
const timezone = (req.headers['x-timezone'] as string) || 'UTC';

if (!token) {
return res.status(403).json({
Expand Down
5 changes: 4 additions & 1 deletion src/utils/axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ export const handleRequest = <T = any>(
internal({
url,
...params,
headers: { 'Content-Type': 'application/json' }
headers: {
'Content-Type': 'application/json',
'x-timezone': Intl.DateTimeFormat().resolvedOptions().timeZone
}
})
.then(handleThen)
.catch(handleCatch);
Expand Down

0 comments on commit 60a64af

Please sign in to comment.