79344749

Date: 2025-01-10 06:11:28
Score: 1.5
Natty:
Report link

@Prakash

I have changed the code to:

const express = require('express');
const app = express();
const bcrypt = require('bcrypt');
const jwt = require('jsonwebtoken');
const sqlite3 = require('sqlite3').verbose();
const path = require('path'); // Required for serving static files
const PORT = process.env.PORT || 3000;

const cors = require('cors');

app.use(cors({
    origin: '*', // Allow both local and network access
    methods: 'GET,POST,PUT,DELETE,OPTIONS',
    allowedHeaders: 'Content-Type,Authorization',
    credentials: true // Allow cookies if necessary
  }));
  
    
app.options('*', cors());

// Middleware for parsing JSON
app.use(express.json());  

// For serving static assets like images
app.use('/assets', express.static(path.join(__dirname, 'assets'), {
setHeaders: (res) => {
    res.setHeader('Access-Control-Allow-Origin', '*');
  }
}));

This allows me to access in Firefox, but not devices on my network.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @Prakash
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Matías Huartamendía