Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CORS error on req too large #977

Merged
merged 1 commit into from
Apr 13, 2023
Merged

Fix CORS error on req too large #977

merged 1 commit into from
Apr 13, 2023

Conversation

kuzdogan
Copy link
Member

@kuzdogan kuzdogan commented Apr 5, 2023

Since the bodyParser, was set before the cors in server.ts, the response will have wrong CORS when body size limit is hit. Move the cors settings above bodyParser.

Also add conditional CORS settings as session requires cookies and "*" CORS is not possible. Remove the individual cors() middleware on every session route in VerificationController.

TODO: - [ ] Add informative message on the UI when HTTP status is 413

View in Huly HI-703

Since the bodyParser, was set before the cors in server.ts, the response
will have wrong CORS when body size limit is hit.
Move the cors settings above bodyParser.

Also add conditional CORS settings as session requires cookies and
"*" CORS is not possible. Remove the individual cors() middleware on
every session route in VerificationController.
@kuzdogan
Copy link
Member Author

I am unable to reproduce this to write the necessary update to the UI 😅 The UI already has a file size check and it shows a message

if (file.size > UI_MAX_FILE_SIZE) {
const humanReadableSize = bytes(file.size);
return setErrorMessage(
`Added file ${
file.name
} is ${humanReadableSize} which is more than the maximum single file size of ${bytes(
UI_MAX_FILE_SIZE
)}`
);
}

image

Opening it for review

@kuzdogan kuzdogan marked this pull request as ready for review April 12, 2023 12:37
Copy link
Member

@marcocastignoli marcocastignoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good

@kuzdogan kuzdogan merged commit 06260e7 into staging Apr 13, 2023
@kuzdogan kuzdogan deleted the req-entity-too-large branch May 10, 2023 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants