Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order confirmation send mail not work #3116

Open
loganess opened this issue Oct 8, 2024 · 17 comments
Open

Order confirmation send mail not work #3116

loganess opened this issue Oct 8, 2024 · 17 comments
Labels
type: bug 🐛 Something isn't working

Comments

@loganess
Copy link

loganess commented Oct 8, 2024

Describe the bug
Vendure doesn't send order confirmation email.

My setting for email plugin as below:

EmailPlugin.init({
	        handlers: [
                ...defaultEmailHandlers,
                orderConfirmationHandler.setOptionalAddressFields(event => {
                    return {
                        cc: '[email protected]',
                        bcc: '[email protected]',
                    }
                }) as any,
            ],
            templateLoader: new FileBasedTemplateLoader(path.join(__dirname, '../static/email/templates')),
	        transport: {
                type: 'smtp',
                host: 'imap.test-domain.com',
                port: 587,
                auth: {
                  user: '[email protected]',
                  pass: 'testpassword',
                },
            },
            globalTemplateVars: {
                // The following variables will change depending on your storefront implementation.
                // Here we are assuming a storefront running at http://localhost:8080.
                fromAddress: '"TEST | shop" <[email protected]>',
                verifyEmailAddressUrl: 'https://shop.test-domain.com/verify',
                passwordResetUrl: 'https://shop.test-domain.com/password-reset',
                changeEmailAddressUrl: 'https://shop.test-domain.com/verify-email-address-change',
            },
        }),
	StripePlugin.init({
    	// This prevents different customers from using the same PaymentIntent
    		storeCustomersInStripe: true,
  	}),

Environment (please complete the following information):

  • @vendure/core version: 3.0.4
  • Nodejs version: 20.17
  • Database (mysql/postgres etc):
@loganess loganess added the type: bug 🐛 Something isn't working label Oct 8, 2024
@pevey
Copy link
Contributor

pevey commented Oct 8, 2024

I assume you're entering your actual smtp credentials and not the example credentials given above? Because those of course will not work. Is there an error shown in the console where Vendure is running?

@loganess
Copy link
Author

loganess commented Oct 8, 2024

Correct. I changed the smtp credential in my post.
There is no error shown in the console, and email is not set in dev mode.

@loganess
Copy link
Author

loganess commented Oct 8, 2024

Also tried to enable debug log for SMTP, but nothing shows up from console.
Email for new account and password recovery request work fine.

@loganess
Copy link
Author

loganess commented Oct 9, 2024

Any idea how to make it works? or do i miss anything?
Thank you.

@pevey
Copy link
Contributor

pevey commented Oct 9, 2024

If I were troubleshooting, I would first make sure the template exists under 'vendure/static/email/templates/order-confirmation'. Then I would copy the template somewhere else and use the default template to make sure it is not a template compilation issue. If still no luck, I would change the config for the email plugin to use the dev mailbox to see if it is maybe an smtp issue.

devMode: true,
outputPath: path.join(__dirname, '../static/email/test-emails'),
route: 'mailbox',

If still no luck, I would make a new folder with a brand new Vendure install and then make changes one by one to try troubleshooting the issue that way.

@pevey
Copy link
Contributor

pevey commented Oct 9, 2024

If you changed the header and/or footer partial, also copy those somewhere else and use the default. Those can cause compilation issues, too. Invalid mjml or hbs will cause the templates to not compile, so the message will not be sent.

@loganess
Copy link
Author

loganess commented Oct 9, 2024

Thanks @pevey
I set to use devMode, and still unable to receive order confirmation email, except generating manually
Also restored all email template includes header and footer.

Screenshot 2024-10-09 at 3 10 16 PM

@pevey
Copy link
Contributor

pevey commented Oct 9, 2024

Try starting with a fresh project and link to the repo with a reproduction of the issue. There's nothing much the vendure team can do without being able to reproduce the error. Starting from a fresh project and changing only the email settings might help you pinpoint the issue.

@loganess
Copy link
Author

Still not able to getting the console log for order confirmation email.
Testing on Ubuntu 24.04, Node 20.17.0
I attached vendure configure file:

import {
    dummyPaymentHandler,
    DefaultJobQueuePlugin,
    DefaultSearchPlugin,
    VendureConfig,
} from '@vendure/core';

import { defaultEmailHandlers, EmailPlugin, FileBasedTemplateLoader } from '@vendure/email-plugin';
import { orderConfirmationHandler } from '@vendure/email-plugin';

import { StripePlugin } from '@vendure/payments-plugin/package/stripe';

import { AssetServerPlugin } from '@vendure/asset-server-plugin';
import { AdminUiPlugin } from '@vendure/admin-ui-plugin';
import 'dotenv/config';
import path from 'path';

const IS_DEV = process.env.APP_ENV === 'dev';
const serverPort = +process.env.PORT || 3000;

export const config: VendureConfig = {
    apiOptions: {
        port: serverPort,
        adminApiPath: 'admin-api',
        shopApiPath: 'shop-api',
        // The following options are useful in development mode,
        // but are best turned off for production for security
        // reasons.
        ...(IS_DEV ? {
            adminApiPlayground: {
                settings: { 'request.credentials': 'include' },
            },
            adminApiDebug: true,
            shopApiPlayground: {
                settings: { 'request.credentials': 'include' },
            },
            shopApiDebug: true,
        } : {}),
    },
    authOptions: {
        tokenMethod: ['bearer', 'cookie'],
        superadminCredentials: {
            identifier: process.env.SUPERADMIN_USERNAME,
            password: process.env.SUPERADMIN_PASSWORD,
        },
        cookieOptions: {
          secret: process.env.COOKIE_SECRET,
        },
    },
    dbConnectionOptions: {
        type: 'postgres',
        // See the README.md "Migrations" section for an explanation of
        // the `synchronize` and `migrations` options.
        synchronize: true,
        migrations: [path.join(__dirname, './migrations/*.+(js|ts)')],
        logging: false,
        database: process.env.DB_NAME,
        schema: process.env.DB_SCHEMA,
        host: process.env.DB_HOST,
        port: +process.env.DB_PORT,
        username: process.env.DB_USERNAME,
        password: process.env.DB_PASSWORD,
    },
    paymentOptions: {
        paymentMethodHandlers: [dummyPaymentHandler],
    },
    // When adding or altering custom field definitions, the database will
    // need to be updated. See the "Migrations" section in README.md.
    customFields: {},
    plugins: [
        AssetServerPlugin.init({
            route: 'assets',
            assetUploadDir: path.join(__dirname, '../static/assets'),
            // For local dev, the correct value for assetUrlPrefix should
            // be guessed correctly, but for production it will usually need
            // to be set manually to match your production url.
            //assetUrlPrefix: IS_DEV ? undefined : 'https://www.my-shop.com/assets/',
	    assetUrlPrefix: 'https://api-shop.test-domain.com/assets/',
        }),
        DefaultJobQueuePlugin.init({ useDatabaseForBuffer: true }),
        DefaultSearchPlugin.init({ bufferUpdates: false, indexStockStatus: true }),
        EmailPlugin.init({
            handlers: [
                ...defaultEmailHandlers,
                orderConfirmationHandler.setOptionalAddressFields(event => {
                  return {
                    cc: '[email protected]',
                    bcc: '[email protected]'
                  }
                }) as any,
            ],
            //templatePath: path.join(__dirname, '../static/email/templates'),
            templatePath: path.join(__dirname, '../static/email/templates'),
	    transport: {
                type: 'smtp',
                host: 'imap.test-domain.com',
                port: 587,
                auth: {
                  user: '[email protected]',
                  pass: 'testpassword',
                },
	    },
            globalTemplateVars: {
                // The following variables will change depending on your storefront implementation
                fromAddress: '"TEST | shop" <[email protected]>',
                verifyEmailAddressUrl: 'https://shop.test-domain.com/verify',
                passwordResetUrl: 'https://shop.test-domain.com/password-reset',
                changeEmailAddressUrl: 'https://shop.test-domain.com/verify-email-address-change'
            },
        }),
	StripePlugin.init({
    	// This prevents different customers from using the same PaymentIntent
    		storeCustomersInStripe: true,
  	}),
        AdminUiPlugin.init({
            route: 'admin',
            port: serverPort + 2,
            adminUiConfig: {
                apiPort: serverPort,
            },
        }),
    ],
};

Console log shows:

shop@vendure3:~/shop$ pwd
/home/shop/shop
[server] > ts-node ./src/index.ts
[server]
[worker] info 10/10/24, 2:06 PM - [Vendure Worker] Bootstrapping Vendure Worker (pid: 127630)...
[server] info 10/10/24, 2:07 PM - [Vendure Server] Bootstrapping Vendure Server (pid: 127632)...
[worker] info 10/10/24, 2:07 PM - [Vendure Worker] Vendure Worker is ready
[worker] info 10/10/24, 2:07 PM - [JobQueue] Starting queue: apply-collection-filters
[worker] info 10/10/24, 2:07 PM - [JobQueue] Starting queue: update-search-index
[worker] info 10/10/24, 2:07 PM - [JobQueue] Starting queue: send-email
[server] info 10/10/24, 2:07 PM - [AdminUiPlugin] Creating admin ui middleware (prod mode)
[server] info 10/10/24, 2:07 PM - [AssetServerPlugin] Creating asset server middleware
[server] info 10/10/24, 2:07 PM - [RoutesResolver] HealthController {/health}:
[server] info 10/10/24, 2:07 PM - [RouterExplorer] Mapped {/health, GET} route
[server] info 10/10/24, 2:07 PM - [RoutesResolver] StripeController {/payments}:
[server] info 10/10/24, 2:07 PM - [RouterExplorer] Mapped {/payments/stripe, POST} route
[server] info 10/10/24, 2:07 PM - [GraphQLModule] Mapped {/shop-api, POST} route
[server] info 10/10/24, 2:07 PM - [GraphQLModule] Mapped {/admin-api, POST} route
[server] info 10/10/24, 2:07 PM - [NestApplication] Nest application successfully started
[server] info 10/10/24, 2:07 PM - [Vendure Server] ================================================
[server] info 10/10/24, 2:07 PM - [Vendure Server] Vendure server (v3.0.4) now running on port 3000
[server] info 10/10/24, 2:07 PM - [Vendure Server] ------------------------------------------------
[server] info 10/10/24, 2:07 PM - [Vendure Server] Shop API:     http://localhost:3000/shop-api
[server] info 10/10/24, 2:07 PM - [Vendure Server] Admin API:    http://localhost:3000/admin-api
[server] info 10/10/24, 2:07 PM - [Vendure Server] Asset server: http://localhost:3000/assets
[server] info 10/10/24, 2:07 PM - [Vendure Server] Admin UI:     http://localhost:3000/admin
[server] info 10/10/24, 2:07 PM - [Vendure Server] ================================================


[server] ValidationError: The 'X-Forwarded-For' header is set but the Express 'trust proxy' setting is false (default). This could indicate a misconfiguration which would prevent express-rate-limit from accurately identifying users. See https://express-rate-limit.github.io/ERR_ERL_UNEXPECTED_X_FORWARDED_FOR/ for more information.
[server]     at Object.xForwardedForHeader (/home/shop/shop/node_modules/express-rate-limit/dist/index.cjs:167:13)
[server]     at Object.wrappedValidations.<computed> [as xForwardedForHeader] (/home/shop/shop/node_modules/express-rate-limit/dist/index.cjs:362:22)
[server]     at Object.keyGenerator (/home/shop/shop/node_modules/express-rate-limit/dist/index.cjs:617:20)
[server]     at /home/shop/shop/node_modules/express-rate-limit/dist/index.cjs:670:32
[server]     at processTicksAndRejections (node:internal/process/task_queues:95:5)
[server]     at async /home/shop/shop/node_modules/express-rate-limit/dist/index.cjs:650:5 {
[server]   code: 'ERR_ERL_UNEXPECTED_X_FORWARDED_FOR',
[server]   help: 'https://express-rate-limit.github.io/ERR_ERL_UNEXPECTED_X_FORWARDED_FOR/'
[server] }

@Balex70
Copy link

Balex70 commented Nov 25, 2024

Still not able to getting the console log for order confirmation email. Testing on Ubuntu 24.04, Node 20.17.0 I attached vendure configure file:

import {
    dummyPaymentHandler,
    DefaultJobQueuePlugin,
    DefaultSearchPlugin,
    VendureConfig,
} from '@vendure/core';

import { defaultEmailHandlers, EmailPlugin, FileBasedTemplateLoader } from '@vendure/email-plugin';
import { orderConfirmationHandler } from '@vendure/email-plugin';

import { StripePlugin } from '@vendure/payments-plugin/package/stripe';

import { AssetServerPlugin } from '@vendure/asset-server-plugin';
import { AdminUiPlugin } from '@vendure/admin-ui-plugin';
import 'dotenv/config';
import path from 'path';

const IS_DEV = process.env.APP_ENV === 'dev';
const serverPort = +process.env.PORT || 3000;

export const config: VendureConfig = {
    apiOptions: {
        port: serverPort,
        adminApiPath: 'admin-api',
        shopApiPath: 'shop-api',
        // The following options are useful in development mode,
        // but are best turned off for production for security
        // reasons.
        ...(IS_DEV ? {
            adminApiPlayground: {
                settings: { 'request.credentials': 'include' },
            },
            adminApiDebug: true,
            shopApiPlayground: {
                settings: { 'request.credentials': 'include' },
            },
            shopApiDebug: true,
        } : {}),
    },
    authOptions: {
        tokenMethod: ['bearer', 'cookie'],
        superadminCredentials: {
            identifier: process.env.SUPERADMIN_USERNAME,
            password: process.env.SUPERADMIN_PASSWORD,
        },
        cookieOptions: {
          secret: process.env.COOKIE_SECRET,
        },
    },
    dbConnectionOptions: {
        type: 'postgres',
        // See the README.md "Migrations" section for an explanation of
        // the `synchronize` and `migrations` options.
        synchronize: true,
        migrations: [path.join(__dirname, './migrations/*.+(js|ts)')],
        logging: false,
        database: process.env.DB_NAME,
        schema: process.env.DB_SCHEMA,
        host: process.env.DB_HOST,
        port: +process.env.DB_PORT,
        username: process.env.DB_USERNAME,
        password: process.env.DB_PASSWORD,
    },
    paymentOptions: {
        paymentMethodHandlers: [dummyPaymentHandler],
    },
    // When adding or altering custom field definitions, the database will
    // need to be updated. See the "Migrations" section in README.md.
    customFields: {},
    plugins: [
        AssetServerPlugin.init({
            route: 'assets',
            assetUploadDir: path.join(__dirname, '../static/assets'),
            // For local dev, the correct value for assetUrlPrefix should
            // be guessed correctly, but for production it will usually need
            // to be set manually to match your production url.
            //assetUrlPrefix: IS_DEV ? undefined : 'https://www.my-shop.com/assets/',
	    assetUrlPrefix: 'https://api-shop.test-domain.com/assets/',
        }),
        DefaultJobQueuePlugin.init({ useDatabaseForBuffer: true }),
        DefaultSearchPlugin.init({ bufferUpdates: false, indexStockStatus: true }),
        EmailPlugin.init({
            handlers: [
                ...defaultEmailHandlers,
                orderConfirmationHandler.setOptionalAddressFields(event => {
                  return {
                    cc: '[email protected]',
                    bcc: '[email protected]'
                  }
                }) as any,
            ],
            //templatePath: path.join(__dirname, '../static/email/templates'),
            templatePath: path.join(__dirname, '../static/email/templates'),
	    transport: {
                type: 'smtp',
                host: 'imap.test-domain.com',
                port: 587,
                auth: {
                  user: '[email protected]',
                  pass: 'testpassword',
                },
	    },
            globalTemplateVars: {
                // The following variables will change depending on your storefront implementation
                fromAddress: '"TEST | shop" <[email protected]>',
                verifyEmailAddressUrl: 'https://shop.test-domain.com/verify',
                passwordResetUrl: 'https://shop.test-domain.com/password-reset',
                changeEmailAddressUrl: 'https://shop.test-domain.com/verify-email-address-change'
            },
        }),
	StripePlugin.init({
    	// This prevents different customers from using the same PaymentIntent
    		storeCustomersInStripe: true,
  	}),
        AdminUiPlugin.init({
            route: 'admin',
            port: serverPort + 2,
            adminUiConfig: {
                apiPort: serverPort,
            },
        }),
    ],
};

Console log shows:

shop@vendure3:~/shop$ pwd
/home/shop/shop
[server] > ts-node ./src/index.ts
[server]
[worker] info 10/10/24, 2:06 PM - [Vendure Worker] Bootstrapping Vendure Worker (pid: 127630)...
[server] info 10/10/24, 2:07 PM - [Vendure Server] Bootstrapping Vendure Server (pid: 127632)...
[worker] info 10/10/24, 2:07 PM - [Vendure Worker] Vendure Worker is ready
[worker] info 10/10/24, 2:07 PM - [JobQueue] Starting queue: apply-collection-filters
[worker] info 10/10/24, 2:07 PM - [JobQueue] Starting queue: update-search-index
[worker] info 10/10/24, 2:07 PM - [JobQueue] Starting queue: send-email
[server] info 10/10/24, 2:07 PM - [AdminUiPlugin] Creating admin ui middleware (prod mode)
[server] info 10/10/24, 2:07 PM - [AssetServerPlugin] Creating asset server middleware
[server] info 10/10/24, 2:07 PM - [RoutesResolver] HealthController {/health}:
[server] info 10/10/24, 2:07 PM - [RouterExplorer] Mapped {/health, GET} route
[server] info 10/10/24, 2:07 PM - [RoutesResolver] StripeController {/payments}:
[server] info 10/10/24, 2:07 PM - [RouterExplorer] Mapped {/payments/stripe, POST} route
[server] info 10/10/24, 2:07 PM - [GraphQLModule] Mapped {/shop-api, POST} route
[server] info 10/10/24, 2:07 PM - [GraphQLModule] Mapped {/admin-api, POST} route
[server] info 10/10/24, 2:07 PM - [NestApplication] Nest application successfully started
[server] info 10/10/24, 2:07 PM - [Vendure Server] ================================================
[server] info 10/10/24, 2:07 PM - [Vendure Server] Vendure server (v3.0.4) now running on port 3000
[server] info 10/10/24, 2:07 PM - [Vendure Server] ------------------------------------------------
[server] info 10/10/24, 2:07 PM - [Vendure Server] Shop API:     http://localhost:3000/shop-api
[server] info 10/10/24, 2:07 PM - [Vendure Server] Admin API:    http://localhost:3000/admin-api
[server] info 10/10/24, 2:07 PM - [Vendure Server] Asset server: http://localhost:3000/assets
[server] info 10/10/24, 2:07 PM - [Vendure Server] Admin UI:     http://localhost:3000/admin
[server] info 10/10/24, 2:07 PM - [Vendure Server] ================================================


[server] ValidationError: The 'X-Forwarded-For' header is set but the Express 'trust proxy' setting is false (default). This could indicate a misconfiguration which would prevent express-rate-limit from accurately identifying users. See https://express-rate-limit.github.io/ERR_ERL_UNEXPECTED_X_FORWARDED_FOR/ for more information.
[server]     at Object.xForwardedForHeader (/home/shop/shop/node_modules/express-rate-limit/dist/index.cjs:167:13)
[server]     at Object.wrappedValidations.<computed> [as xForwardedForHeader] (/home/shop/shop/node_modules/express-rate-limit/dist/index.cjs:362:22)
[server]     at Object.keyGenerator (/home/shop/shop/node_modules/express-rate-limit/dist/index.cjs:617:20)
[server]     at /home/shop/shop/node_modules/express-rate-limit/dist/index.cjs:670:32
[server]     at processTicksAndRejections (node:internal/process/task_queues:95:5)
[server]     at async /home/shop/shop/node_modules/express-rate-limit/dist/index.cjs:650:5 {
[server]   code: 'ERR_ERL_UNEXPECTED_X_FORWARDED_FOR',
[server]   help: 'https://express-rate-limit.github.io/ERR_ERL_UNEXPECTED_X_FORWARDED_FOR/'
[server] }

I have the same error ( The 'X-Forwarded-For' header is set but the Express 'trust proxy' setting is false (default)) in my log when trying to start project with Kubernetes. I use ingress with nginx controller
I tried to add this into vendure-config.ts

...
import { Application } from 'express';
...
export const config: VendureConfig = {
    apiOptions: {
        port: serverPort,
        adminApiPath: 'admin-api',
        shopApiPath: 'shop-api',
        middleware: [
            {
                 // Set 'trust proxy' for Express
                handler: (app: Application) => {
                    app.set('trust proxy', 1); // Trust the first proxy
                    console.log('Trust proxy is set to 1');
                },
                route: '*', // Apply to all routes
                beforeListen: true, // Ensure this runs before the server starts listening
            },
        ],
 ...

but no luck, throw me error "TypeError: app.set is not a function"

Also tried this also

 ...
import { Application } from 'express';
import { NestExpressApplication } from '@nestjs/platform-express';
...
export const config: VendureConfig = {
    apiOptions: {
        port: serverPort,
        adminApiPath: 'admin-api',
        shopApiPath: 'shop-api',
        middleware: [
            {
               // Set 'trust proxy' for Express
                handler: (app: NestExpressApplication) => {
                    // Access the underlying Express application and set 'trust proxy'
                    const expressApp = app.getHttpAdapter().getInstance() as Application;
                    expressApp.set('trust proxy', 1); // Trust the first proxy
                    console.log('Trust proxy is set to 1');
                },
                route: '*', // Apply to all routes
                beforeListen: true, // Ensure this runs before the server starts listening
            },
        ],
 ...

Different error this time "TypeError: app.getHttpAdapter is not a function"
Can anyone help with this?

@sqpollen
Copy link

Did you ever get this working @Balex70?

@michaelbromley
Copy link
Member

An important note here is that email sending is done by the worker, not the server. Ensure your worker process is running when testing this out.

@sqpollen
Copy link

Thanks @michaelbromley - Im having the issue in general. App is deployed to ECS/Cloudfront.

Heres some logs

[server] ValidationError: The 'X-Forwarded-For' header is set but the Express 'trust proxy' setting is false (default). This could indicate a misconfiguration which would prevent express-rate-limit from accurately identifying users. See https://express-rate-limit.github.io/ERR_ERL_UNEXPECTED_X_FORWARDED_FOR/ for more information.
[server] at Object.xForwardedForHeader (/usr/src/app/node_modules/.pnpm/[email protected][email protected]/node_modules/express-rate-limit/dist/index.cjs:187:13)
[server] at wrappedValidations.<computed> [as xForwardedForHeader] (/usr/src/app/node_modules/.pnpm/[email protected][email protected]/node_modules/express-rate-limit/dist/index.cjs:398:22)
[server] at Object.keyGenerator (/usr/src/app/node_modules/.pnpm/[email protected][email protected]/node_modules/express-rate-limit/dist/index.cjs:671:20)
[server] at /usr/src/app/node_modules/.pnpm/[email protected][email protected]/node_modules/express-rate-limit/dist/index.cjs:724:32
[server] at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
[server] at async /usr/src/app/node_modules/.pnpm/[email protected][email protected]/node_modules/express-rate-limit/dist/index.cjs:704:5 {
[server]   code: 'ERR_ERL_UNEXPECTED_X_FORWARDED_FOR',
[server]   help: 'https://express-rate-limit.github.io/ERR_ERL_UNEXPECTED_X_FORWARDED_FOR/'
[server] }
[server] info 1/15/25, 6:33 AM - [Vendure Server] ================================================
[server] info 1/15/25, 6:33 AM - [Vendure Server] Admin UI: http://localhost:3000/admin
[server] info 1/15/25, 6:33 AM - [Vendure Server] Dev mailbox: http://localhost:3000/mailbox

@michaelbromley
Copy link
Member

@sqpollen

[Vendure Server] Dev mailbox: http://localhost:3000/mailbox

this indicates that Vendure is configured with the EmailPlugin in dev mode, which means emails will not be sent, but will be saved as files

Just making sure here - are you reporting that emails do not work for you, or are you commenting related to the "trust proxy" error. Or both?

@Balex70
Copy link

Balex70 commented Jan 15, 2025

Did you ever get this working @Balex70?

Not yet, for now, I'm working on local only and using docker. Maybe I will get back to kubernetes later

@sqpollen
Copy link

@sqpollen

[Vendure Server] Dev mailbox: http://localhost:3000/mailbox

this indicates that Vendure is configured with the EmailPlugin in dev mode, which means emails will not be sent, but will be saved as files

Just making sure here - are you reporting that emails do not work for you, or are you commenting related to the "trust proxy" error. Or both?

Sorry for confusion - my comments are purely for the trust proxy error . I havent used the emails yet.

@sqpollen
Copy link

sqpollen commented Jan 15, 2025

@sqpollen

[Vendure Server] Dev mailbox: http://localhost:3000/mailbox

this indicates that Vendure is configured with the EmailPlugin in dev mode, which means emails will not be sent, but will be saved as files
Just making sure here - are you reporting that emails do not work for you, or are you commenting related to the "trust proxy" error. Or both?

Sorry for confusion - my comments are purely for the trust proxy error . I havent used the emails yet.

I got this working by adding the following to vendure config

apiOptions: {
    middleware: [
      {
        route: "/",
        handler: (req: any, res: any, next: any) => {
          req.app.set("trust proxy", (ip: string, index: number) => {
            const cfRequestId = req.get("x-amz-cf-id");
            const cfViewer = req.get("cloudfront-viewer-address");
            return Boolean(cfRequestId && cfViewer);
          });
          next();
        },
      },
    ],
....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants