Skip to content

Commit

Permalink
fix(cookie): set cookie with "SameSite=strict"
Browse files Browse the repository at this point in the history
  • Loading branch information
robertu7 committed Sep 22, 2020
1 parent f1e01e5 commit 7a949b0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/common/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ export const CORS_OPTIONS: CorsOptions = {
return callback(null, false)
}

const isLocalDev = /(localhost|127\.0\.0\.1)$/.test(origin)
const isLocalDev = /(localhost|127\.0\.0\.1):\d+$/.test(origin)
const isMatters = /\/\/(.*\.)?matters\.news$/.test(origin)
const isApolloStudio = /\/\/(.*\.)?apollographql\.com$/.test(origin)
const isAllowed = isLocalDev || isMatters || isApolloStudio
Expand Down
5 changes: 3 additions & 2 deletions src/common/utils/cookie.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Request, Response } from 'express'
import { CookieOptions, Request, Response } from 'express'

import {
COOKIE_TOKEN_NAME,
Expand All @@ -12,7 +12,8 @@ const getCookieOption = (req: Request) => {
httpOnly: true,
secure: req.protocol === 'https',
domain: req.hostname,
}
sameSite: 'strict',
} as CookieOptions
}

export const setCookie = ({
Expand Down

0 comments on commit 7a949b0

Please sign in to comment.