Skip to content

Improve WW API Data Sanitation. #277

@AndlerRL

Description

@AndlerRL

Validate and Sanitize External API Responses Before Forwarding

Directly forwarding the external API's response to the client without validation may pose security risks. The external API could return unexpected or malicious data. It's recommended to parse and validate the response content before sending it to the client to ensure that no harmful or sensitive data is transmitted.

Consider modifying the code to parse the response and safely send it to the client:

- return new NextResponse(response.body, {
-   headers: {
-     'Content-Type': 'text/event-stream',
-     'Cache-Control': 'no-cache',
-     'Connection': 'keep-alive',
-   },
- });
+ const data = await response.json();
+ return NextResponse.json(data, {
+   headers: {
+     'Cache-Control': 'no-cache',
+     'Connection': 'keep-alive',
+   },
+ });

Committable suggestion was skipped due to low confidence.

Originally posted by @coderabbitai[bot] in #276 (comment)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions