allow any domain config setting
This commit is contained in:
parent
241b1b1f47
commit
b1a79242aa
|
@ -2,7 +2,7 @@ import { FragmentSchema } from '@/config/fragments/types';
|
|||
|
||||
export const devFragment: FragmentSchema = {
|
||||
server: {
|
||||
cors: 'http://localhost:5173',
|
||||
allowAnySite: true,
|
||||
trustProxy: true,
|
||||
},
|
||||
logging: {
|
||||
|
|
|
@ -9,6 +9,10 @@ export const configSchema = z.object({
|
|||
// space seperated list of allowed cors domains
|
||||
cors: z.string().default(''),
|
||||
|
||||
// disable cross origin restrictions, allow any site.
|
||||
// overwrites the cors option above
|
||||
allowAnySite: z.coerce.boolean().default(false),
|
||||
|
||||
// should it trust reverse proxy headers? (for ip gathering)
|
||||
trustProxy: z.coerce.boolean().default(false),
|
||||
|
||||
|
|
|
@ -56,8 +56,10 @@ export async function setupFastify(): Promise<FastifyInstance> {
|
|||
|
||||
// plugins
|
||||
log.info(`setting up plugins`, { evt: 'setup-plugins' });
|
||||
const corsDomains = conf.server.cors.split(' ').filter((v) => v.length > 0);
|
||||
const corsSetting = conf.server.allowAnySite ? true : corsDomains;
|
||||
await app.register(cors, {
|
||||
origin: conf.server.cors.split(' ').filter((v) => v.length > 0),
|
||||
origin: corsSetting,
|
||||
credentials: true,
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue