I use the following configuration for setting the CDN prefix for media files in my sitecore. But when viewing a page within the experience editor, none of the images can be reached by the CMS as the page is not public and behind a login wall.
I'm using Sitecore XP Single 9.0.2 and wa
<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"
xmlns:set="http://www.sitecore.net/xmlconfig/set/">
<sitecore>
<settings>
<!--Set the Media Server URL to the Azure CDN endpoint-->
<setting name="Media.MediaLinkServerUrl">
<patch:attribute name="value">https://sitecore-dev-cdn.azureedge.net</patch:attribute>
</setting>
<!--This will cause the Media Link Provider to include the above URL in the media links that are rendered.-->
<setting name="Media.AlwaysIncludeServerUrl">
<!--SET THIS VALUE TO FALSE WHEN WORKING IN A LOCAL DEV ENVIRONMENT-->
<patch:attribute name="value">false</patch:attribute>
</setting>
<!--Cacheability needs to be set to public, otherwise the CDN will not cache media.-->
<setting name="MediaResponse.Cacheability">
<patch:attribute name="value">public</patch:attribute>
</setting>
</settings>
</sitecore>
</configuration>