Merge pull request #16514 from fortuna/master

Fix CORS definition on restify
This commit is contained in:
Arthur Ozga
2017-05-19 13:11:52 -07:00
committed by GitHub
2 changed files with 11 additions and 9 deletions

View File

@@ -595,15 +595,12 @@ export function auditLogger(options: { log: any }): (req: Request, res: Response
export function fullResponse(): RequestHandler;
// tslint:disable-next-line no-var
export var defaultResponseHeaders: any;
export interface CORS {
(cors?: {
origins?: string[];
credentials?: boolean;
headers?: string[];
}): RequestHandler;
origins: string[];
ALLOW_HEADERS: string[];
credentials: boolean;
export function CORS(options?: CORSOptions): RequestHandler;
export interface CORSOptions {
origins?: string[];
credentials?: boolean;
headers?: string[];
}
export const pre: {

View File

@@ -254,6 +254,11 @@ server.use(restify.queryParser());
server.use(restify.jsonp());
server.use(restify.gzipResponse());
server.use(restify.bodyParser());
server.use(restify.CORS({
origins: ['https://foo.com', 'http://bar.com', 'http://baz.com:8081'],
credentials: true,
headers: ['x-foo']
}));
server.use(restify.throttle({
burst: 100,
rate: 50,