Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed vercel Backend Login issue #803

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading