open-wa/wa-automate-nodejs
The issue has been closed
ERROR when running behind nginx proxy #1686
the-jojo-jj posted onGitHub
Hi, i've found open-wa runs by direct hit:
> curl --location --request POST 'http://192.168.45.3:7020/sendText' \
--header 'api_key: 744858c547272xxxxxxx' \
--header 'Content-Type: application/json' \
--data-raw '{
"args": {
"to": "4474472xxxxx@c.us",
"content": "Hello World!”
}
}'
but, when put behind the nginx reverse proxy with following config:
location /v01/wa/xxxxxxx/ {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
proxy_redirect off;
proxy_set_header host $host;
proxy_set_header X-real-ip $remote_addr;
proxy_set_header X-forward-for $proxy_add_x_forwarded_for;
proxy_pass http://192.168.45.3:7020/;
}
i've got:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>SyntaxError: Unexpected token <br> in JSON at position 74<br> at JSON.parse (<anonymous>)<br> at parse (/root/.npm/_npx/21fe510f43113ad2/node_modules/body-parser/lib/types/json.js:89:19)<br> at /root/.npm/_npx/21fe510f43113ad2/node_modules/body-parser/lib/read.js:121:18<br> at invokeCallback (/root/.npm/_npx/21fe510f43113ad2/node_modules/raw-body/index.js:224:16)<br> at done (/root/.npm/_npx/21fe510f43113ad2/node_modules/raw-body/index.js:213:7)<br> at IncomingMessage.onEnd (/root/.npm/_npx/21fe510f43113ad2/node_modules/raw-body/index.js:273:7)<br> at IncomingMessage.emit (node:events:377:35)<br> at endReadableNT (node:internal/streams/readable:1312:12)<br> at processTicksAndRejections (node:internal/process/task_queues:83:21)</pre>
</body>
</html>