i am getting a same error When i try to connect my node.js server in a react-native expo app. My SSL is working correctly on Postman but native is giving an error. Do you know how can i solve this?
My Native Code:
const serverUrl = "https://israbilisim.com/api/user/login";
const calistir = async () => {try {const response = await axios.post(serverUrl,{username: user,},{headers: {"Content-Type": "application/json",},});
catch (error) {console.error("İstekte bir hata oluştu:", error.code);if (error.response) {console.error("Sunucu Hatası:", error.response.data);console.error("Durum Kodu:", error.response.status);alert("Sunucu Hatası: " + error.response.data);else if (error.request) {console.error("Yanıt Alınamadı:", error.request);alert("Sunucuya ulaşılamadı, lütfen bağlantınızı kontrol edin.");else {console.error("Hata:", error.message);alert("Beklenmeyen bir hata oluştu: " + error.message);}}
};
Native Error Message:
ERROR İstekte bir hata oluştu: ERR_NETWORKERROR Yanıt Alınamadı: {"DONE": 4, "HEADERS_RECEIVED": 2, "LOADING": 3, "OPENED": 1, "UNSENT": 0, "\_aborted": false, "\_cachedResponse": undefined, "\_hasError": true, "\_headers": {"accept": "application/json, text/plain, */*", "content-type": "application/json"}, "\_incrementalEvents": false, "\_lowerCaseResponseHeaders": {}, "\_method": "POST", "\_perfKey": "network_XMLHttpRequest\_https://israbilisim.com/api/user/login", "\_performanceLogger": {"\_closed": false, "\_extras": {}, "\_isGlobalLogger": true, "\_pointExtras": {}, "\_points": {"initializeCore_end": 68889819.826771, "initializeCore_start": 68889659.412503}, "\_timespans": {"network_XMLHttpRequest\_http://192.168.3.153:8081/symbolicate": \[Object\], "network_XMLHttpRequest\_https://israbilisim.com/api/user/login": \[Object\]}}, "\_requestId": null, "\_response": "java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.", "\_responseType": "", "\_sent": true, "\_subscriptions": \[\], "\_timedOut": false, "\_trackingName": "unknown", "\_url": "https://israbilisim.com/api/user/login", "readyState": 4, "responseHeaders": undefined, "status": 0, "timeout": 0, "upload": {}, "withCredentials": true}
My Server index.js:
const express = require("express");const https = require("https");const fs = require("fs");> //const cors = require("cors");const axios = require("axios");const app = express();const PORT = 443; // HTTPS için genellikle kullanılan portconst sql = require("mssql");const userRoutes = require("./routes/UserRoutes");const dataRoutes = require("./routes/DataRoutes");app.use(express.json());//app.use(cors());const options ={key: fs.readFileSync("isra/server.key"), // Özel anahtarın yolucert: fs.readFileSync("isra/israbilisim_com.crt"), // Sertifika dosyasının yolu> };app.use("/api/user", userRoutes);app.use("/api/data", dataRoutes);const server = https.createServer(options, app);server.listen(PORT, () => {console.log(HTTPS Server is running on port ${PORT});> });