credentials header

This commit is contained in:
vigdorov
2020-07-03 22:51:56 +03:00
parent 0ddee4a35c
commit 9238629bd1
3 changed files with 7 additions and 2 deletions

View File

@ -1,4 +1,5 @@
export const DB_NAME = '/store-service';
export const MONGO_URL = `mongodb://localhost:27017${DB_NAME}`;
export const ALLOW_ORIGIN_ALL: [string, string] = ['Access-Control-Allow-Origin', '*'];
export const ALLOW_CREDENTIALS: [string, string] = ['Access-Control-Allow-Credentials', 'true'];
export const ALLOW_METHOD: [string, string] = ['Access-Control-Request-Method', 'POST DELETE PUT GET'];

View File

@ -2,7 +2,7 @@ import { Controller, Get, Post, Body, Param, Header, Delete } from '@nestjs/comm
import {StoreService} from './store.service';
import {Store, StoreResponse, StoreRequest} from './store.schema';
import {ApiResponse} from '@nestjs/swagger';
import {ALLOW_ORIGIN_ALL, ALLOW_METHOD} from 'src/consts';
import {ALLOW_ORIGIN_ALL, ALLOW_METHOD, ALLOW_CREDENTIALS} from 'src/consts';
@Controller('store')
export class StoreController {
@ -13,6 +13,7 @@ export class StoreController {
@Get()
@Header(...ALLOW_ORIGIN_ALL)
@Header(...ALLOW_METHOD)
@Header(...ALLOW_CREDENTIALS)
@ApiResponse({
status: 200,
description: 'Список всех пар ключ-значение',
@ -25,6 +26,7 @@ export class StoreController {
@Get(':key')
@Header(...ALLOW_ORIGIN_ALL)
@Header(...ALLOW_METHOD)
@Header(...ALLOW_CREDENTIALS)
@ApiResponse({
status: 200,
description: 'Возвращает пару ключ-значение по ключу',
@ -37,6 +39,7 @@ export class StoreController {
@Post()
@Header(...ALLOW_ORIGIN_ALL)
@Header(...ALLOW_METHOD)
@Header(...ALLOW_CREDENTIALS)
@ApiResponse({
status: 200,
description: 'Создает новую пару ключ-значение или заменяет существующую по ключу',
@ -49,6 +52,7 @@ export class StoreController {
@Delete(':key')
@Header(...ALLOW_ORIGIN_ALL)
@Header(...ALLOW_METHOD)
@Header(...ALLOW_CREDENTIALS)
@ApiResponse({
status: 200,
description: 'Удаляет пару ключ-значение по ключу',