Skip to content

Commit

Permalink
Merge pull request #803 from IkkiOcean/vercel-backend
Browse files Browse the repository at this point in the history
Fixed vercel Backend Login issue
  • Loading branch information
manikumarreddyu authored Nov 5, 2024
2 parents d12de86 + ad8afdd commit a832b35
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 22 deletions.
15 changes: 1 addition & 14 deletions backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,7 @@ const bcrypt = require('bcryptjs')
require("./services/passport")
const app = express();

app.use(cors({
origin: "http://localhost:5173",
origin:"https://agro-tech-ai.vercel.app/",
credentials: true,
}));

// app.use(cors({
// origin: "http://localhost:5173", // Ensure no trailing slash
// methods: "GET,POST,PUT,DELETE,OPTIONS",
// allowedHeaders: "Content-Type,Authorization",
// credentials: true,
// }));

app.use(cors());
app.use(cors()); // This allows all origins to access your API

app.use(
session({
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/AgroRentAI/NavigateProducts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const RentalMarketplace = () => {
useEffect(() => {
const fetchProducts = async () => {
try {
const response = await fetch(`http://localhost:8080/api/rent-products`);
const response = await fetch(`https://agrotech-ai-11j3.onrender.com/api/rent-products`);
const data = await response.json();
setProducts(data);
setFilteredProducts(data); // Initialize filteredProducts
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/AgroRentAI/components/AgriProductListing.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const AgriProductListing = () => {
useEffect(() => {
const fetchProducts = async () => {
try {
const response = await axios.get("http://localhost:8080/api/products");
const response = await axios.get("https://agrotech-ai-11j3.onrender.com/api/products");
setProducts(response.data);
} catch (err) {
console.error("Error fetching products:", err);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const Footer = () => {
}

try {
const response = await fetch("http://localhost:8080/api/rating", {
const response = await fetch("https://agrotech-ai-11j3.onrender.com/api/rating", {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/ForgotPassword.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const ForgotPasswordPage = () => {

const handleSendOtp = async () => {
try {
await axios.post("http://localhost:8080/auth/forgot-password", { email });
await axios.post("https://agrotech-ai-11j3.onrender.com/auth/forgot-password", { email });
toast.success("OTP sent to your email address");
setStep(2); // Move to OTP verification step
} catch (error) {
Expand All @@ -22,7 +22,7 @@ const ForgotPasswordPage = () => {

const handleVerifyOtp = async () => {
try {
await axios.post("http://localhost:8080/auth/verify-otp", { email, otp });
await axios.post("https://agrotech-ai-11j3.onrender.com/auth/verify-otp", { email, otp });
toast.success("OTP verified. Enter your new password.");
setStep(3); // Move to password reset step
} catch (error) {
Expand All @@ -32,7 +32,7 @@ const ForgotPasswordPage = () => {

const handleResetPassword = async () => {
try {
await axios.post("http://localhost:8080/auth/reset-password", { email, otp, newPassword });
await axios.post("https://agrotech-ai-11j3.onrender.com/auth/reset-password", { email, otp, newPassword });
toast.success("Password reset successfully. Please log in.");
setTimeout(() => {
<Navigate to="/login" replace />;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/SignUpPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const SignUpPage = () => {

try {
const response = await axios.post(
"http://localhost:8080/auth/signup",
"https://agrotech-ai-11j3.onrender.com/auth/signup",
{
firstName,
lastName,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Contact.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const Contact = () => {

try {
// Send form data to backend
const response = await fetch('http://localhost:8080/api/contactus', {
const response = await fetch('https://agrotech-ai-11j3.onrender.com/api/contactus', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down

0 comments on commit a832b35

Please sign in to comment.