Fix connection
This commit is contained in:
1 parent
4ad665cac0
commit
b8a847c210
12 files changed
+56
-18
No files matched your search
@@ -0,0 +1,32 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const dir = 'c:\\Users\\Goura\\AntigravityProjects\\LogManager\\frontend\\src';
|
||||
|
||||
function replaceInFile(filePath) {
|
||||
let content = fs.readFileSync(filePath, 'utf8');
|
||||
let original = content;
|
||||
|
||||
// Pattern 1: single quotes
|
||||
content = content.replace(/'http:\/\/localhost:3001([^']*)'/g, "`${import.meta.env.VITE_API_URL || 'http://localhost:3001'}$1`");
|
||||
|
||||
// Pattern 2: backticks (template literals)
|
||||
// Avoid double injecting if already replaced
|
||||
content = content.replace(/`http:\/\/localhost:3001([^`]*)`/g, "`${import.meta.env.VITE_API_URL || 'http://localhost:3001'}$1`");
|
||||
|
||||
if (content !== original) {
|
||||
fs.writeFileSync(filePath, content);
|
||||
console.log("Updated", filePath);
|
||||
}
|
||||
}
|
||||
|
||||
function walk(dir) {
|
||||
const list = fs.readdirSync(dir);
|
||||
for (let file of list) {
|
||||
file = path.resolve(dir, file);
|
||||
const stat = fs.statSync(file);
|
||||
if (stat && stat.isDirectory()) walk(file);
|
||||
else if (file.endsWith('.ts') || file.endsWith('.tsx')) replaceInFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
walk(dir);
|
||||
Reference in new issue
Block a user