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

Media url not correct when using FileStorage in a subdirectory. #1898

Open
darkson95 opened this issue Jul 6, 2022 · 3 comments
Open

Media url not correct when using FileStorage in a subdirectory. #1898

darkson95 opened this issue Jul 6, 2022 · 3 comments

Comments

@darkson95
Copy link

Hello,
first of all thank you for the project!

I plan to run the web app on an IIS in a subfolder https://example.com/Piranha. When I run the project in Visual Studio, the application runs directly in root https://localhost:7645.

Now I have the problem that the images from the media library are not displayed on both systems at the same time. In the settings I found the field "Media CDN". If I set that, it works on the IIS, but not locally anymore. If I remove it, it works locally and not on the IIS. I am using the same database for local development and the staging server.

I found the issue #1658, but it does not deal with the media library. Is there an easy way to set the Media CDN to only use it when the HTTP request is not local? Is there a better solution?

@sayganov
Copy link
Contributor

sayganov commented Jul 8, 2022

@tidyui, would the following solution work?

  1. Add a new flag to ConfigModel called something like UseMediaCdnOnLocalhost
  2. Add migrations
  3. Add a checkbox next to the MediaCDN input on the Configuration page to update UseMediaCdnOnLocalhost value
  4. Update the Get method of the Config service to provide the flag
  5. Update the frontend part to use MediaCDN on localhost when UseMediaCdnOnLocalhost is true

@tidyui
Copy link
Member

tidyui commented Sep 29, 2022

The media CDN is not intended to be used like this, the idea with the CDN setting is if you want to upload images to one location (filesystem, storage) but want to fetch them when rendering the UI from a different URL. The issue would rather be related to that the application path when running in a subdirectory is not considered when generating local file system URL:s.

@tidyui tidyui changed the title Media CDN local and on IIS Subdirectory Media url not correct when using FileStorage in a subdirectory. Sep 29, 2022
@tidyui tidyui added this to the Version 10.3 milestone Sep 29, 2022
@tidyui tidyui modified the milestones: Version 10.3, Version 10.4 Jan 19, 2023
@tidyui
Copy link
Member

tidyui commented Jun 6, 2023

I know it's been a while, but I'm having a hard time seeing why this wouldn't work in you case @darkson95. The PublicUrl property for a local asset is calculated to something like:

~/uploads/<id>/<filename>

Given that ~/ should be evaluated to your application root in ASP.NET, if used correctly in the website rendering the image the url should be correct both when the application is running in the root and in an application folder.

Best regards

@tidyui tidyui removed this from the Version 10.4 milestone Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants