chore: Update environment configuration for API URL and enhance next.config.ts with rewrites and CORS headers

This commit is contained in:
yoosangwook 2025-04-29 10:23:15 +09:00
parent 866de531fa
commit 58662400cb
9 changed files with 99 additions and 63 deletions

View File

@ -0,0 +1,3 @@
# 모바일 디바이스로 로컬 서버 확인하려면 자신 IP 주소로 변경
# 다시 로컬에서 개발할때는 localhost로 변경
NEXT_PUBLIC_API_URL=http://localhost:3000

View File

View File

@ -0,0 +1 @@
NEXT_PUBLIC_API_URL=http://172.30.1.35:3000

View File

@ -6,6 +6,35 @@ const nextConfig: NextConfig = {
sassOptions: {
includePaths: [path.join(__dirname, './src/styles')],
},
async rewrites() {
return [
{
source: '/:path*',
destination: `${process.env.NEXT_PUBLIC_API_URL}/:path*`,
},
]
},
async headers() {
return [
{
source: '/api/:path*',
headers: [
{
key: 'Access-Control-Allow-Origin',
value: '*',
},
{
key: 'Access-Control-Allow-Methods',
value: 'GET, POST, PUT, DELETE, OPTIONS',
},
{
key: 'Access-Control-Allow-Headers',
value: 'Content-Type, Authorization',
},
],
},
]
},
}
export default nextConfig

View File

@ -119,8 +119,7 @@ model SD_SERVEY_SALES_BASIC_INFO {
//제출일
submission_date DateTime? @db.Date
//상세정보
detail_info SD_SERVEY_SALES_DETAIL_INFO @relation(fields: [detail_info_id], references: [id])
detail_info_id Int @unique
detail_info SD_SERVEY_SALES_DETAIL_INFO?
created_at DateTime @default(now())
updated_at DateTime @updatedAt
}
@ -201,5 +200,6 @@ model SD_SERVEY_SALES_DETAIL_INFO {
memo String? @db.VarChar(500)
created_at DateTime @default(now())
updated_at DateTime @updatedAt
basic_info SD_SERVEY_SALES_BASIC_INFO?
basic_info SD_SERVEY_SALES_BASIC_INFO @relation(fields: [basic_info_id], references: [id])
basic_info_id Int @unique
}

View File

@ -24,12 +24,14 @@ export async function POST(request: Request) {
const cookieStore = await cookies()
const session = await getIronSession<SessionData>(cookieStore, sessionOptions)
console.log('start session edit!')
session.username = user.username!
session.email = user.email!
session.isLoggedIn = true
console.log('end session edit!')
await session.save()
console.log('🚀 ~ POST ~ session:', session)
// return NextResponse.redirect(new URL(process.env.NEXT_PUBLIC_URL!, request.url))
return NextResponse.json(user)
}

View File

@ -26,7 +26,7 @@ export default function RootLayout({
}>) {
return (
<html lang="en">
<body className={`${geistSans.variable} ${geistMono.variable} antialiased`}>
<body>
<ReactQueryProviders>{children}</ReactQueryProviders>
<Footer />
</body>

View File

@ -23,11 +23,11 @@ export default function SurveySales() {
store: 'HWJ(T01)',
construction_point: 'HWJ(T01)',
investigation_date: '2025-04-28',
building_name: '한화재팬빌딩',
building_name: 'Hanwha Japan Building',
customer_name: 'Hong Gil Dong',
post_code: '1050013',
address: '서울특별시 강남구 테헤란로 14길 6 ',
address_detail: '남도빌딩 2층',
address: 'Tokyo, Japan',
address_detail: '1-1-1',
submission_status: false,
}
@ -44,10 +44,10 @@ export default function SurveySales() {
<button className="bg-blue-500 text-white px-4 py-2 rounded-md"></button>
</div>
</div>
<div className="bg-orange-100 border-l-4 border-orange-500 text-orange-700 p-4 m-4" role="alert">
{/* <div className="bg-orange-100 border-l-4 border-orange-500 text-orange-700 p-4 m-4" role="alert">
<p className="font-bold">Be Warned</p>
<p> .</p>
</div>
</div> */}
</>
)
}

View File

@ -7,6 +7,7 @@ import { SessionData, sessionOptions } from './libs/session'
export async function middleware(request: NextRequest) {
const cookieStore = await cookies()
const session = await getIronSession<SessionData>(cookieStore, sessionOptions)
console.log('🚀 ~ middleware ~ session:', session)
if (!session.isLoggedIn) {
return NextResponse.redirect(new URL('/login', request.url))
}