Skip to content

Commit

Permalink
desci.com cookie config
Browse files Browse the repository at this point in the history
  • Loading branch information
shadrach-tayo committed Sep 5, 2024
1 parent a3923d7 commit e80aa3e
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Description of the Problem / Feature

## Explanation of the solution

## Instructions on making this work

## Describe environment variable changes

## Preview of changes
34 changes: 34 additions & 0 deletions .github/workflows/analyze.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Analyze Bundle

on: [push]

jobs:
analyze_bundle:
runs-on: ubuntu-16gb
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "npm"

# Maybe unnecessary, but prevents this job from racing to set the cache key
# with the test workflow
- uses: actions/cache/restore@v4
id: cache-modules
with:
path: node_modules
key: modules-${{ hashFiles('package-lock.json')}}

# If no full node_modules hit, install and prefer global package cache.
- if: steps.cache-modules.outputs.cache-hit != 'true'
run: npm ci --prefer-offline --no-audit

- run: npm run analyze

- name: Archive bundle analysis
uses: actions/upload-artifact@v3
with:
name: bundle-analysis.zip
path: .next/analyze/*.html
1 change: 1 addition & 0 deletions src/apis/queries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { DoiRecord } from "./types";
export async function getDois() {
const response = await fetch(`${NODES_API_URL}/v1/admin/doi/list`, {
credentials: "include",
mode: "cors",
});

const data = (await response.json()) as
Expand Down
26 changes: 25 additions & 1 deletion src/app/actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,31 @@ export async function login(prevState: any, formData: FormData) {

if (response.ok && response.user) {
// Set cookie
cookies().set(AUTH_COOKIE_FIELDNAME, response.user.token);
cookies().set(AUTH_COOKIE_FIELDNAME, response.user.token, {
path: "/",
expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30 * 1), // 1 month
httpOnly: true,
secure: process.env.NEXT_ENV === "production",
domain: process.env.NODE_ENV === "production" ? ".desci.com" : undefined,
});

if (process.env.NEXT_ENV === "production") {
cookies().set(AUTH_COOKIE_FIELDNAME, response.user.token, {
path: "/",
expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30 * 1), // 1 month
httpOnly: true,
secure: true,
domain: "nodes.desci.com",
});
cookies().set(AUTH_COOKIE_FIELDNAME, response.user.token, {
path: "/",
expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30 * 1), // 1 month
httpOnly: true,
secure: true,
domain: ".desci.com",
});
}

redirect(`/`);
}

Expand Down

0 comments on commit e80aa3e

Please sign in to comment.