import env from '#start/env' import { Secret } from '@adonisjs/core/helpers' import { defineConfig } from '@adonisjs/core/http' import { shouldUseSecureCookies } from '../app/utils/cookie_security.js' /** * The app key is used for encrypting cookies, generating signed URLs, * and by the "encryption" module. * * The encryption module will fail to decrypt data if the key is lost or * changed. Therefore it is recommended to keep the app key secure. */ export const appKey = new Secret(env.get('APP_KEY')) const secureCookies = shouldUseSecureCookies(env.get('URL')) /** * The configuration settings used by the HTTP server */ export const http = defineConfig({ generateRequestId: true, allowMethodSpoofing: false, /** * Enabling async local storage will let you access HTTP context * from anywhere inside your application. */ useAsyncLocalStorage: false, /** * Manage cookies configuration. The settings for the session id cookie are * defined inside the "config/session.ts" file. */ cookie: { domain: '', path: '/', maxAge: '2h', httpOnly: true, secure: secureCookies, sameSite: 'lax', }, })