Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deny using iframes and add allowed headers in cors #10

Open
bmxpiku opened this issue Mar 23, 2023 · 0 comments
Open

Deny using iframes and add allowed headers in cors #10

bmxpiku opened this issue Mar 23, 2023 · 0 comments

Comments

@bmxpiku
Copy link

bmxpiku commented Mar 23, 2023

https://www.oreilly.com/library/view/nodejs-web-development/9781788626859/3d40c77e-d328-401b-bcc0-fdd6f71c2774.xhtml
Unless you expect to use iframe- helmet by default allows 'sameorigin', then I would advise denying it.

Also, cors settings could have headers defined (this is my cors.ts file definition, but I deliver api for couple of frontend applications):

const whitelist = process.env.CORS_ORIGINS?.split('|') || [];

export default {
  origin(origin: string | undefined, callback: (arg0: Error, arg1?: boolean) => void): void {
    if (!origin || whitelist.some((val) => origin.match(val))) {
      callback(null, true);
    } else {
      callback(new Error('Not allowed by CORS'));
    }
  },
  maxAge: 86400,
  headers: [
    'Accept',
    'Authorization',
    'Content-Type',
    'If-None-Match',
    'BX-User-Token',
    'Trace-Id',
  ],
  exposedHeaders: ['WWW-Authenticate', 'Server-Authorization'],
  credentials: true,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant