fixed proxy for backend and route api calls, do not use node environment property when in production
This commit is contained in:
parent
5f0e56abec
commit
26b2367c8d
Binary file not shown.
Binary file not shown.
@ -1,4 +1,13 @@
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {};
|
||||
const nextConfig = {
|
||||
async rewrites() {
|
||||
return [
|
||||
{
|
||||
source: '/backend/:path*',
|
||||
destination: `http://192.168.50.107:5580/:path*`,
|
||||
},
|
||||
]
|
||||
},
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
|
||||
@ -2,10 +2,11 @@
|
||||
"name": "kevos-attire",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"proxy": "http://192.168.50.107:5580/",
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"start": "next start -p 3003",
|
||||
"lint": "next lint"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
"use server"
|
||||
import { sendEmails } from "@/lib/mail.utils"
|
||||
import { NextRequest } from "next/server"
|
||||
import { NextRequest, NextResponse } from "next/server"
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
const sender = {
|
||||
@ -18,14 +19,18 @@ export async function POST(request: NextRequest) {
|
||||
const result = await sendEmails({
|
||||
sender,
|
||||
recipients,
|
||||
subject: "New Email!",
|
||||
message: `New order from ${clientEmail}`
|
||||
subject: "New Order!",
|
||||
message: `New order from ${clientEmail.senderEmail}`
|
||||
})
|
||||
|
||||
return Response.json({
|
||||
return NextResponse.json({
|
||||
accepted: result.accepted,
|
||||
})
|
||||
} catch (error){
|
||||
return Response.json({message: 'Unable to send email at this time.'}, {status: 500})
|
||||
return NextResponse.json({message: 'Unable to send email at this time.'}, {status: 500})
|
||||
}
|
||||
}
|
||||
|
||||
export async function GET(req: NextRequest){
|
||||
return NextResponse.json({message: 'Hello'})
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 25 KiB |
BIN
frontend/src/app/icon.png
Normal file
BIN
frontend/src/app/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
@ -37,24 +37,21 @@ export default function Home() {
|
||||
|
||||
// Send new order email to self
|
||||
const clientEmail = formData.get('senderEmail') as string
|
||||
console.log(JSON.stringify({"senderEmail":clientEmail}))
|
||||
await fetch("/api/emails", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(clientEmail),
|
||||
body: JSON.stringify({"senderEmail":clientEmail}),
|
||||
})
|
||||
// .then((response) => response.json())
|
||||
// .then((data) => {
|
||||
// console.log(data);
|
||||
// })
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
|
||||
|
||||
// const response = await fetch("http://192.168.50.107:5580/new-order", {
|
||||
const response = await fetch("http://localhost:5080/new-order", {
|
||||
const response = await fetch("/backend/new-order", {
|
||||
// const response = await fetch("http://localhost:5080/new-order", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-type": "application/json",
|
||||
@ -62,9 +59,6 @@ export default function Home() {
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
.then((response) => response.json())
|
||||
// .then((data) => {
|
||||
// console.log(data);
|
||||
// })
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
@ -74,7 +68,7 @@ export default function Home() {
|
||||
emails: "",
|
||||
orders: "",
|
||||
});
|
||||
// alert("Order Placed! Please check your email.")
|
||||
alert("Order Placed! Please check your email.")
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
"use server"
|
||||
import nodemailer from "nodemailer";
|
||||
import Mail from "nodemailer/lib/mailer";
|
||||
import SMTPTransport from "nodemailer/lib/smtp-transport";
|
||||
import * as React from 'react';
|
||||
|
||||
const transport = nodemailer.createTransport({
|
||||
host: process.env.MAIL_HOST,
|
||||
port: process.env.MAIL_PORT,
|
||||
secure: process.env.NODE_ENV !== 'development', //true
|
||||
// secure: process.env.NODE_ENV !== 'development', //true // DO NOT USE FOR PRODUCTION BUILD
|
||||
auth: {
|
||||
user: process.env.MAIL_USER,
|
||||
pass: process.env.MAIL_PASSWORD
|
||||
|
||||
Loading…
Reference in New Issue
Block a user