processing / processing/p5.js

[p5.js 2.0+ Bug Report]: no referrer leading to errors with OpenStreetMap

Open
#9,195 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

p5.js 2.0+
Dominant language
JavaScript
Stars
24k
Forks
3.8k
Avg merge
3d 16h
Merged PRs (30d)
25

Description

Most appropriate sub-area of p5.js?
  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • WebGPU
  • p5.strands
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)
p5.js version

2.3.2

Web browser and version

Firefox 155.0.1

Operating system

MacOS

Steps to reproduce this

This seems to be an error for the web editor specifically (not the library). I teach a class where I have students use Mappa.js library (easier on-ramp than Leaflet) within the p5.js web editor to create interactive maps. We have mostly been using OpenStreetMap as our map provider because it does not require API keys or tokens. However, OSM now requires a valid Referer/User-Agent to identify, and it seems that the web editor iframe may be blocking anything referrer from getting sent.

Here is a screenshot of the error:

Image
Steps:
  1. Create a new project in p5.js web editor
  2. Use the index.html and sketch.js code below
  3. Click Run
Snippet:

index.html:

<!DOCTYPE html>
<html lang="en">
  <head>
     <meta name="referrer" content="strict-origin-when-cross-origin">
   <script src="https://unpkg.com/mappa-mundi@0.0.5/dist/mappa.js" type="text/javascript"></script>
    <script src="https://cdn.jsdelivr.net/npm/p5@2.3.2/lib/p5.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/p5.sound@0.4.1/dist/p5.sound.min.js"></script>
    <link rel="stylesheet" type="text/css" href="style.css">
    <meta charset="utf-8" />

  </head>
  <body>
    <main>
    </main>
    <script src="sketch.js"></script>
  </body>
</html>

sketch.js:

let myMap;
let canvas;
const mappa = new Mappa("Leaflet");

const options = {
  lat: -40,
  lng: 55,
  zoom: 0.5,
  style: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
};

function setup() {
  canvas = createCanvas(800, 800);
    myMap = mappa.tileMap(options);
  myMap.overlay(canvas);
}

function draw() {
clear();
}

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

Reproduce the problem in a new p5.js web editor project using the provided index.html and sketch.js with Mappa.js and the OpenStreetMap tile URL. Start by examining how the web editor iframe handles referrer information for external tile requests. Done means the example can load OpenStreetMap tiles with the required request metadata, or the limitation and supported workaround are clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.