今日已更新 393 条资讯 | 累计 25473 条内容
关于我们

serving static data to the front-end

/u/MEHDII__ 2026年05月27日 16:27 2 次阅读 来源:Reddit r/webdev

I am trying to build a guess-the-x sort of game/quiz, a full stack application, the stack doesn't matter, I was trying to find a way to send an API payload to my front-end securely without users being able to cheat by inspecting the payload using the requests devtools tab. the idea of this quiz is users are given a pixelated image, and many game details like title, summary, devs, pubs, platforms etc... depending on the difficulty I reveal to the users a percentage of the hints early, e.g. easy they can 30% of [devs, pubs, summary, etc...] 15% at medium, and 0% at hard. the image cannot be unpixelated manually however, at each wrong guess it unpixelated automatically, but for other indicators users can "unredact" them using hint points, (3 in total) obviously if not designed properly this is very each to cheat if a user is even slighly tech savvy since the backend sends the entire payload as-is to the client, what i did was my payload response looks something like this: { summary: { { text: "xxxxxxxxxxxxxxxxxxxxxx", revealded: false, text: "something something", revealed : true } } } and i store game state in redis that way i dont have to hit my database for every post request the client makes to fetch the game data; the redis state looks something like this { answer : game.title, hints_left: 3, guesses_made: 0, full_game_data : game, } then the other issue is the game cover, the data isnt mine, prior to this i had built an ETL pipeline to ingest data from IGDB's api, i only save their cover id to my database, something like 1234abc. so on the initial GET request, i hit their CDN endpoint, get the cover, process it in the backend, (pixelization), base64 encode it, which im aware that encoding binaries to base64 is a 1.37x increase over the original data, but i found no way of transmitting images securely to the front end except this one; so im asking for recommendations. right now this is a little slow, even on local host it could reach 2s for image load, mainly beca

本文内容来源于互联网,版权归原作者所有
查看原文