Loading article…
How to Move FiveM Images and NUI Assets to a CDN
Migrate FiveM inventory images, phone media and public NUI assets to a CDN without breaking URLs, uploads or resource delivery.
Migrate FiveM inventory images, phone media and public NUI assets to a CDN without breaking URLs, uploads or resource delivery.
Loading article…
Moving FiveM media to a CDN is not only an upload task. The real migration is changing every script, database record and interface that depends on the old URLs without interrupting the server.
Start by separating public assets from connection resources. Inventory icons, phone photos, videos, screenshots and web-loaded NUI assets can use stable CDN URLs. Vehicles, maps, clothing and other files downloaded as FiveM resources belong on the resource cache path instead.
A CDN is the right destination when a file needs a stable public URL that can be loaded by a script, NUI page, website, Discord embed or browser.
Common CDN candidates include:
Do not move every file simply because it is large. A clothing pack or map downloaded while the player connects is still a FiveM resource. Use a FiveM cache proxy for that path.
Before uploading, find every place that constructs or stores a URL.
Search:
Record the current base URL, folder convention, filename rules, expected content types and which service writes each file.
This is also the time to identify dead files and duplicated paths. Migrating unused objects makes the cutover slower and preserves confusion you could remove first.
Use folders that reflect how the files are operated, not the name of whichever VPS currently hosts them.
For example:
inventory/items/water.png
inventory/items/repair-kit.png
phone/photos/player-123/2026/08/photo.jpg
police/evidence/case-456/clip.mp4
nui/dispatch/icons/priority.svg
vehicles/thumbnails/adder.webp
Stable conventions make URLs predictable and make future cleanup safer. Avoid putting secrets, license identifiers or internal hostnames in public paths.
When several scripts already agree on relative paths, preserve those paths under the new CDN base URL. That can turn a large migration into one base-URL change instead of thousands of individual replacements.
Inventory images, job logos and NUI assets are usually the safest first batch because they change less often than player uploads.
Content-Type.Keep the old files available during this phase. Removing them before every script has been updated turns a reversible migration into an outage.
Prefer one configurable CDN base URL:
local cdnBaseUrl = "https://cdn.example.com"
local itemIcon = ("%s/inventory/items/%s.png"):format(cdnBaseUrl, itemName)
The specific integration will differ by script, but the principle stays the same. Keep the base URL in server-side configuration or a shared resource instead of scattering it through many files.
For NUI bundles, confirm whether an asset is loaded by an absolute public URL or packaged with the resource. Do not point a bundled relative import at a CDN without checking how the build tool rewrites it.
Phone systems and evidence tools often store full URLs in the database.
If the path after the hostname stays identical, a controlled hostname replacement may be possible. If the folder structure changes, create an explicit mapping and update records in batches.
Before changing production data:
Do not rewrite every URL in the database based only on a broad text replacement. Other domains, malformed values and historical formats may exist in the same column.
Migrating old media solves only half of the problem. The phone, evidence or upload script also needs to send new files to the CDN.
Keep permanent service credentials on the server side. A client-visible NUI or Lua resource should request a short-lived, scoped upload target rather than receive a reusable API key.
A safer upload flow is:
Client asks your server for upload permission
-> server validates the player and file
-> server requests a short-lived upload URL
-> client uploads to that target
-> final public URL is stored by the script
The FiveMesh CDN API documentation and scoped upload guide cover the current integration options.
A URL opening in one browser tab does not prove every FiveM interface can use it.
Test images in NUI, videos with seeking, and uploads from the actual resource. Confirm the CDN returns the correct content type and supports the browser behavior the script expects. Video players may rely on partial requests, while NUI requests may depend on suitable CORS behavior.
Use representative files rather than one tiny PNG. A migration can look complete until the first larger video or less common MIME type reaches production.
When an asset changes, decide whether the public URL should remain stable.
For versioned application assets, a new filename such as dispatch-v2.js or a content hash makes the change explicit. For stable inventory paths, replace the object and use the CDN purge workflow when the old response must be invalidated.
Do not purge unrelated FiveM Cache entries when changing a public CDN image. CDN assets and connection resources are different products with different cache identities.
Real servers eventually reference a missing icon or deleted media object.
FiveMesh CDN can apply pattern-based placeholders so paths such as inventory/items/* return a deliberate fallback image when the requested object is missing. That protects the interface while the underlying path is corrected.
Read CDN Placeholders for Missing FiveM Images for the complete fallback flow. A placeholder is a safer failure mode, not a reason to ignore broken paths permanently.
Build a short cutover checklist for each asset group.
Leave the old host available for a defined observation window. Remove it only when production traffic and script behavior show that the migration is complete.
FiveMesh CDN provides public URLs, dashboard uploads, object browsing, folders, API access, scoped upload flows, purge operations and placeholders for common FiveM media workflows.
For the broader storage and security model, read How to Host FiveM Images, Videos and Phone Media. If the files are downloaded when players connect, use the fileserver_add and adhesive_cdnKey setup guide instead.
A safe CDN migration is incremental: classify the files, preserve useful paths, update one consumer at a time, verify new uploads, and retire the old host only after the traffic has moved.