---
title: "MailDev: inline attachment URLs in TypeScript | VulCode"
description: "A fix to MailDev in TypeScript: cid: links to inline attachments in an email now point to the real API route and work under a subpath as well as at the root."
url: "https://vulcode.com/en/opensource/contributions/maildev"
lang: "en"
---

[All contributions](https://vulcode.com/en/opensource/contributions)

maildev/maildev

# MailDev

An SMTP server with a web interface for testing email during development.

[See the repository](https://github.com/maildev/maildev) [All contributions](https://vulcode.com/en/opensource/contributions)

- **Language**: TypeScript
- **GitHub stars**: 6,164
- **Merged changes**: 1
- **Project site**: [maildev.github.io](https://maildev.github.io/maildev/)

## What we changed

replaceCidReferences rewrites cid: links to inline attachments onto the real /api/email/:id/attachment/:file route together with the base path, so the URL works at the root and under a subpath.

### What this work shows

- cid: references in HTML email

- Apps served under a base path

- Root-relative URLs

What was broken

### cid: links led to a route that did not exist

replaceCidReferences rewrote cid: links in the email HTML to /email/:id/attachment/:file. No such route existed, since attachments are served from /api/... under the configured base path.

How we fixed it

### A URL with /api and the base path

The URL is now root-relative and includes the base path and /api, so it works at the root and under a subpath such as /mail. A base path of / adds no prefix, and tests also cover base paths given with and without slashes.

[#582](https://github.com/maildev/maildev/pull/582)

## Merged change 1

- [#582 Build CID attachment URLs against the API route and base path Merged 22 September 2026](https://github.com/maildev/maildev/pull/582)

## What it taught us

An app that can run under a subpath must build every URL from the base path, not from the domain root. We test edge cases such as a base path of /, so no //api/... URL appears that a browser would read as another host.

[More about this technology: TypeScript, React and Node](https://vulcode.com/en/technologies/typescript-react-and-node)

## Other projects we write code for

- [**Material UI** JavaScript · 99,391 stars A React component library that implements Google's Material Design: ready-made text fields, selects, buttons and other interface elements.](https://vulcode.com/en/opensource/contributions/material-ui)

- [**Grafana** TypeScript · 78,050 stars An open observability and data visualisation platform that shows metrics, logs and traces from Prometheus, Loki, Elasticsearch, PostgreSQL and many other sources on dashboards.](https://vulcode.com/en/opensource/contributions/grafana)

- [**Marked** TypeScript · 37,323 stars A fast Markdown parser and compiler to HTML, written in TypeScript and following CommonMark and GitHub Flavored Markdown.](https://vulcode.com/en/opensource/contributions/marked)

- [**Autoprefixer** JavaScript · 22,197 stars A PostCSS plugin that adds browser prefixes to CSS based on Can I Use data, including the -ms-grid syntax for CSS Grid layouts.](https://vulcode.com/en/opensource/contributions/autoprefixer)

- [**Lichess** TypeScript · 19,013 stars The lichess.org chess server: free, ad-free and open source, focused on real-time play. The back end is written in Scala, the interface in TypeScript.](https://vulcode.com/en/opensource/contributions/lichess)

- [**compromise** JavaScript · 12,176 stars A natural language processing library in JavaScript: it splits text into sentences and words, tags parts of speech, conjugates verbs and inflects nouns, and reads dates through a plugin. It runs in the browser and in Node.js.](https://vulcode.com/en/opensource/contributions/compromise)

## Describe your project.

A free quote comes back within an hour during working hours.

### Rather skip the form?

Ask in the chat or write to us directly.

Open the chat

- **Email**: [hello@vulcode.com](mailto:hello@vulcode.com)
- **Phone**: [+48 576 043 920](tel:+48576043920)
- **Discord**: [discord.gg/vulcode](https://discord.gg/vulcode)
