veertech / localstack-aws-ses-email-viewer

Localstack AWS SES Email Viewer
8 stars 4 forks source link

Error connecting to localstack #43

Closed Spatbee closed 1 hour ago

Spatbee commented 2 hours ago

When I run curl localhost:4566/_aws/ses I do get the expected response, all the emails stored in localstack SES.

However, I start my docker image with docker run --rm --env LOCALSTACK_HOST=http://localstack:4566 -p 3005:3005 ses-viewer I get the following error when loading the landing page:

FetchError: request to http://localstack:4566/_aws/ses failed, reason: getaddrinfo ENOTFOUND localstack
    at ClientRequest.<anonymous> (file:///app/node_modules/node-fetch/src/index.js:108:11)
    at ClientRequest.emit (node:events:517:28)
    at Socket.socketErrorListener (node:_http_client:501:9)
    at Socket.emit (node:events:517:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
veelenga commented 1 hour ago

It seems that the error you're encountering is related to the DNS resolution failure for the hostname. This issue often arises in Docker environments because the container cannot resolve the hostname unless it's explicitly defined in the networking setup.

Try running them on the same docker network:

docker network create localstack-net
docker run --rm --name localstack --network localstack-net -p 4566:4566 localstack/localstack
docker run --rm --env LOCALSTACK_HOST=http://localstack:4566 --network localstack-net -p 3005:3005 ses-viewer
Spatbee commented 14 minutes ago

Yes that was it, thank you.

Unfortunately, our project sends templated emails which don't seem to be readable by your app. I'm not sure they could be without recreating the SES templating logic. Thank you for taking a look into my problem though.

TypeError: Cannot read properties of undefined (reading 'html_part')
    at createEmail (file:///app/app.js:143:24)
    at file:///app/app.js:19:27
    at Array.map (<anonymous>)
    at file:///app/app.js:18:16
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
veelenga commented 4 minutes ago

@Spatbee this is strange, is your message without body?

Can you give us an example of the email available at http://localstack:4566/_aws/ses ?