[NestJS] redirect
페이지 정보
작성자 sbLAB 댓글 0건 조회 32회 작성일 24-05-08 23:46본문
auth.controller.ts
import {
Body,
Controller,
Get,
Post,
HttpCode,
Render,
HttpStatus,
Header,
Res,
Redirect,
} from '@nestjs/common';
import { AuthService } from './auth.service';
import { UserDto } from 'src/user/dto/UserDto';
import { response } from 'express';
@Controller('auth')
export class AuthController {
constructor(private authService: AuthService) {}
@Get()
@Render('auth/auth') //auth index page
authView() {
return this.authService.authView();
}
@Get('logout') //auth logout execution
authLogOutExec() {
const result = this.authService.authLogOutExec();
}
@Post('signup') //auth signup execution
@HttpCode(HttpStatus.CREATED) //201
//@Redirect('/', 301) //함수 실행종료후 리다이렉션
//Common HTTP Status Codes
//200 OK: The request was successful.
//201 Created: The request was successful, and a new resource was created.
//400 Bad Request: The server could not understand the request.
//404 Not Found: The requested resource could not be found
async authSignUpExec(@Body() userDto: UserDto, @Res() res) {
const result = await this.authService.authSignUpExec(userDto);
return res.redirect('/');
}
OR
@Post('signup') //auth signup execution
@HttpCode(HttpStatus.CREATED) //201
@Redirect('/', 301) //함수 실행종료후 리다이렉션
//Common HTTP Status Codes
//200 OK: The request was successful.
//201 Created: The request was successful, and a new resource was created.
//400 Bad Request: The server could not understand the request.
//404 Not Found: The requested resource could not be found
async authSignUpExec(@Body() userDto: UserDto, @Res() res) {
const result = await this.authService.authSignUpExec(userDto);
//return res.redirect('/');
}
- 이전글[nestjs] session, cookie 설정 / 브라우저 쿠키와 서버 세션 작동관계 24.05.12
- 다음글[NestJS] 윈도우 NestJS 개발환경 - 리눅스 Ubuntu NestJS 개발 환경 24.05.02
댓글목록
등록된 댓글이 없습니다.