fix(nui): use internal proxy to bypass mixed content & bump node engine#33
Open
Jaysigx wants to merge 2 commits intoitschip:mainfrom
Open
fix(nui): use internal proxy to bypass mixed content & bump node engine#33Jaysigx wants to merge 2 commits intoitschip:mainfrom
Jaysigx wants to merge 2 commits intoitschip:mainfrom
Conversation
|
This has undergone full testing with over 16,000 images no errors produced. |
Owner
|
Hey @Jaysigx , I'll test it out today! Thanks for the PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Title: Fix NUI Mixed Content Upload Errors & Node Engine Unavailability
What this PR fixes:
TypeError: Failed to fetchon NUI Uploads (Mixed Content/CORS):When third-party resources (like
lb-phoneorrcore_clothing_for_photos) usescreenshot-basic'srequestScreenshotUploadinside a secure modern FiveMui_pagecontext (https://cfx-nui...), Chrome's strict security policies natively blockfetch('http://[server-ip]/upload').Additionally, the Koa router previously ignored
OPTIONSpreflight requests, immediately returning a405 Method Not Allowed, thereby failing the CORS check.enginesStrict Check Failure:FiveM's built-in Resource Builder uses a bundled Node
v16.9.1runtime executable. Becausepackage.jsonstrictly enforced"node": ">=22.0.0", FiveM's internal Yarn builder forcefully crashed out during the automatic install process, preventing users from simply starting the script out of the box.How it was fixed:
"engines"restriction entirely frompackage.jsonto let FiveM's integrated Yarn seamlessly fetch/install packages.serverEndpointwhich suffers from WebKit secure context isolation, I created a dedicated NUI callback (screenshot_upload_proxy).The frontend NUI now seamlessly encodes the image as a
base64string and passes it down to the Client Lua/JS environment instantly. The Client then usesTriggerLatentServerEventto proxy the Base64 stream directly to the Server.FormDatastructure before forwarding the payload directly to the external webhook vianode-fetch.