mapbox / mapbox/mapbox-gl-js

Add option to set request mode for fetch API

Open Beginner friendly
#13,676 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged feature :green_apple:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

Motivation

It is not strictly necessary in most cases, but if I know I only use URLs from the same-origin it can be better to use mode: 'same-security' for fetch requests to block cross origin requests altogether.

It isn't strictly necessary but it could be used to avoid accidentally calling CORS URLs

Implementation

In https://github.com/mapbox/mapbox-gl-js/blob/v3.24.0/src/util/ajax.ts#L118 add an option to also provide mode similar to cache mode etc.

See also https://developer.mozilla.org/en-US/docs/Web/API/Request/mode and https://developer.mozilla.org/en-US/docs/Web/API/RequestInit#mode

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/util/ajax.ts around line 118 and compare the existing request options with the Fetch RequestInit mode documentation linked in the issue. Done means callers can provide a request mode and same-origin-only requests can prevent cross-origin fetches; verify the behavior with the project's relevant checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, web-dev
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.