Skip to content

Commit

Permalink
Merge pull request #60 from supertokens/59-missing-req-body
Browse files Browse the repository at this point in the history
fix: Add a default empty request body for network requests
  • Loading branch information
rishabhpoddar authored Dec 12, 2022
2 parents bfa6a0f + e1c25ba commit 118d2fc
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

## [0.2.5] - 2022-12-12

- Adds an empty request body for all APIs by default to prevent body validation failures (https://github.com/supertokens/dashboard/issues/59)

## [0.2.4] - 2022-11-28

- Fixed an issue where the user's name would render incorrectly
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,4 @@ You can now access the production build of the dashboard on `http://localhost:30
- Dashboard changes that involve adding new features and do not require backend SDK changes will increment the Z version
- UI changes that modify existing features or are fixes or enhancements increment the Z version
- X version changes should be reserved for overhauls of the entire dashboard
- After making a change, if it is important for the changes to reflect immediately for a patch release you can use https://purge.jsdelivr.net/gh/supertokens/[email protected]/build/static/js/bundle.js to purge jsdelivr cache. Make sure to change `X.Y` with the version you want to purge the cache for.
2 changes: 1 addition & 1 deletion build/static/js/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/static/js/bundle.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dashboard",
"version": "0.2.4",
"version": "0.2.5",
"private": true,
"dependencies": {
"@babel/core": "^7.16.0",
Expand Down
15 changes: 15 additions & 0 deletions src/services/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,23 @@ export default class NetworkManager {
return this.delete(url, query, config);
}

/**
* If the user's backend has a validation for the request body being missing, it is
* possible that it will fail for some of the dashboard requests (for example api
* key validation).
*
* This ensures that a body is always sent to the server even if the API itself does
* not consume it
*/
let bodyToUse: BodyInit = JSON.stringify({});

if (config !== undefined && config.body !== null && config.body !== undefined) {
bodyToUse = config.body;
}

return fetch(new URL(url), {
...config,
body: bodyToUse,
method,
headers: {
...config?.headers,
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
* under the License.
*/

export const package_version = "0.2.4";
export const package_version = "0.2.5";

0 comments on commit 118d2fc

Please sign in to comment.