Skip to content

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

Description

@angichau

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();
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions