HTML modified by gateway gets reset on client by JS
Unanswered
Cyanide posted this in #help-forum
CyanideOP
Hi! I have a sort of placeholder in final compiled build
However, on client this code is also shipped as JS and gets reset to that value before it was modified. I verified this by looking at JS. If I disable JS initial HTML is shown fine in dev tools otherwise when I enable, I see the replaced JS.
<meta id='FE_APP_CONFIG_IDENTIFIER' />
and my static gateway which serves this HTML finds this identifier and replaces it with some value. However, on client this code is also shipped as JS and gets reset to that value before it was modified. I verified this by looking at JS. If I disable JS initial HTML is shown fine in dev tools otherwise when I enable, I see the replaced JS.
3 Replies
@Cyanide Hi! I have a sort of placeholder in final compiled build `<meta id='FE_APP_CONFIG_IDENTIFIER' />` and my static gateway which serves this HTML finds this identifier and replaces it with some value.
However, on client this code is also shipped as JS and gets reset to that value before it was modified. I verified this by looking at JS. If I disable JS initial HTML is shown fine in dev tools otherwise when I enable, I see the replaced JS.
hmm maybe try some tricks like
<script
dangerouslySetInnerHtml={{
__html: "</script><meta id='FE_APP_CONFIG_IDENTIFIER' /><script>"
}}
/>
but yeah, nextjs does not fare too well when it comes to a proxy modifying html before it's served to the client
you can also make a js script to add the <meta> tag, then you can simply <script> that script and use your proxy to edit the script