Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR:
/debug/opengraph
The opengraph image needs to be accessible from a url like
http://unicove.com/en/eos/og_default.png
in the head of the document, but we also need some way of changing the image parameters e.g. title, text, layout, language, etc.There were two approaches I considered to include all the various options we needed for generation:
http://unicove.com/en/eos/layout-1/Title%20of%20the%20image/Text%20of%20image/og_default.png
orhttp://unicove.com/en/eos/og_default.png?text=Text%20of%20image&layout=1
Upside to this approach is all configuration could happen at the
+page.ts
load function of the particular route.But using params like this would open the api to potential abuse and create massive urls. Even with a token-based authentication between unicove.com and the image-generator service, anyone could just change the query params and unicove would generate a valid image
example:
http://unicove.com/en/eos/send
uses the image athttp://unicove.com/en/eos/api/og/send.png
which uses the predefined options for that route (text, title, layout, language, network, etc.)The upside is no invalid images can be generated, but the tradeoff is all configuration needs to be done in a centralized place (in this case, the object at the api endpoint)
Note: two new env variables are needed
API_OPENGRAPH_GENERATOR
is the url of the endpoint for the image generatorAPI_OPENGRAPH_TOKEN
is the shared token that matches the endpoint