Skip to content

Commit

Permalink
Reajuste despliegue sin api
Browse files Browse the repository at this point in the history
  • Loading branch information
PELUQAZ committed Dec 5, 2024
1 parent cdca875 commit 6588df9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/main_wmc-agreements-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ jobs:
npm run test --if-present
- name: Zip artifact for deployment
run: zip release.zip ./* -r
run: |
cd test/front
zip -r ../../release.zip ./*
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
Expand Down
6 changes: 5 additions & 1 deletion api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,18 @@ app.use(
app.use((req, res, next) => {
const allowedOrigins = [
'https://workmarketcap.myshopify.com',
'https://workmarketcap.com'
'https://workmarketcap.com',
'http://127.0.0.1:5500'
];
const origin = req.headers.origin;

if (allowedOrigins.includes(origin)) {
res.setHeader('Access-Control-Allow-Origin', origin);
}

//res.setHeader('Access-Control-Allow-Origin', 'https://workmarketcap.myshopify.com'); // Reemplaza con el dominio de tu tienda
//res.setHeader('Access-Control-Allow-Origin', 'http://127.0.0.1:5500'); // Reemplaza con el dominio de tu tienda

res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE'); // Métodos que permites
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization'); // Cabeceras que permites
next();
Expand Down
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"name": "wmc-api-blockchain-polygon",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"dev": "node api/index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
Expand Down
16 changes: 8 additions & 8 deletions test/front/wmc-front-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ async function loadConfig() {
'http://localhost:3000' : window.location.origin
//const response = await fetch("/api/config");
//const response = await fetch("http://localhost:3000/api/config");
const response = await fetch(`${baseUrl}/api/config`);
//const response = await fetch(`${baseUrl}/api/config`);

const config = await response.json();
contractAddress = config.contractAddress;
usdcTokenAddress = config.usdcTokenAddress;
apiBaseUrl = config.apiBaseUrl;
//const config = await response.json();
contractAddress = '0xE2e2b4297c51bF174b656F064BA3cb82095A5399'; //config.contractAddress;
usdcTokenAddress = '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359'; //config.usdcTokenAddress;
apiBaseUrl = baseUrl; //config.apiBaseUrl;

} catch (error) {
console.error("Error al cargar config.json:", error);
Expand All @@ -41,10 +41,11 @@ async function loadConfig() {

// Función para conectar Metamask
async function connectWallet() {

if (typeof ethers === "undefined") {
console.error("ethers.js no se cargó correctamente. Revisa el archivo 'ethers.umd.min.js'");
}
//console.log("ethers.utils = ", ethers.utils);

if (!ethers.utils) {
console.error("ethers.js no está cargado correctamente.");
} else {
Expand All @@ -57,11 +58,10 @@ async function connectWallet() {
const userAddress = accounts[0];
// Guarda la dirección en localStorage para usarla luego
localStorage.setItem('userAddress', userAddress);
console.log(`Wallet connected: ${userAddress}`);
console.log(`Wallet conectada: ${userAddress}`);
// Muestra la dirección en el campo "Wallet proveedor servicio (freelancer)"
document.getElementById("servicePayer").value = userAddress;
})
//console.log("Wallet conectada:", await signer.getAddress());
} catch (error) {
console.error("Error al conectar con Metamask:", error);
}
Expand Down

0 comments on commit 6588df9

Please sign in to comment.