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

Fix missing images everywhere when running locally #2019

Closed
wants to merge 2 commits into from

Conversation

YoshiRulz
Copy link
Collaborator

@YoshiRulz YoshiRulz commented Oct 20, 2024

Before/after:
side-by-side
Only has effect in dev environments.

@YoshiRulz
Copy link
Collaborator Author

Build failure is here:

_model = new RenderModel(_mockWikiPages, _db, NullLogger<RenderModel>.Instance)

I'm not sure how to get an IHostEnvironment at that point. DI via a constructor parameter prevents the test from running.

@adelikat
Copy link
Collaborator

You have to mock it

@Masterjun3
Copy link
Collaborator

Is this the right place to insert a dev fallback? It relies on the broken links to be redirected to the wiki endpoint.
Instead, couldn't this be implemented more properly in the options when we add the UseStaticFiles. Maybe by adding a dev FileProvider that uses the regular file provider and doing the fallback logic there?

@adelikat
Copy link
Collaborator

I looked and I see no way to do this kind of routing with UseStaticFiles. The best I found is to put some custom middleware, but thsi would mean that we would either always have the dummy images locally (which i do not want, since I have the correct ones) or the middleware would need to do some kind of check if the image exists, which we get for free with this approach. This might be a bit hacky but I don't see a less hacky alternative

@Masterjun3
Copy link
Collaborator

@adelikat I mentioned doing it by overriding the StaticFileOptions.FileProvider in the UseStaticFiles call with our own IFileProvider implementation that does this.
Wouldn't that be a good way to do this?

@adelikat
Copy link
Collaborator

I would need an example. I tried to do that approach and it seemed impossible

@Masterjun3
Copy link
Collaborator

I can give an example in a week if that's okay.

@Masterjun3
Copy link
Collaborator

@adelikat I posted my example in PR #2062 .

@adelikat
Copy link
Collaborator

adelikat commented Jan 4, 2025

Closing in favor of this approach: #2062

@adelikat adelikat closed this Jan 4, 2025
@YoshiRulz YoshiRulz deleted the local-missing-images branch January 4, 2025 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants