Skip to content

Commit

Permalink
Revert 4e6b7aa
Browse files Browse the repository at this point in the history
(re: #1130)

Apparently the `api.openstreetmap.org` won't work with OAuth2 yet.
It currently tries to redirect to `www.openstreetmap.org` which triggers a
CORS issue (the 2 domains are considered different origins)

Will hold off on this for now and watch openstreetmap/operations#951
  • Loading branch information
bhousel committed Oct 23, 2023
1 parent 4e6b7aa commit 4cc756d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
context.assetPath = '';
context.apiConnections = [
{
url: 'https://api.openstreetmap.org',
url: 'https://www.openstreetmap.org',
client_id: 'O3g0mOUuA2WY5Fs826j5tP260qR3DDX7cIIE2R2WWSc',
client_secret: 'b4aeHD1cNeapPPQTrvpPoExqQRjybit6JBlNnxh62uE'
}, {
Expand Down
2 changes: 1 addition & 1 deletion dist/latest.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
context.assetPath = 'https://cdn.jsdelivr.net/npm/@rapideditor/rapid@2/dist/';
context.apiConnections = [
{
url: 'https://api.openstreetmap.org',
url: 'https://www.openstreetmap.org',
client_id: 'O3g0mOUuA2WY5Fs826j5tP260qR3DDX7cIIE2R2WWSc',
client_secret: 'b4aeHD1cNeapPPQTrvpPoExqQRjybit6JBlNnxh62uE'
}, {
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
context.assetPath = 'dist/';
context.apiConnections = [
{
url: 'https://api.openstreetmap.org',
url: 'https://www.openstreetmap.org',
client_id: 'O3g0mOUuA2WY5Fs826j5tP260qR3DDX7cIIE2R2WWSc',
client_secret: 'b4aeHD1cNeapPPQTrvpPoExqQRjybit6JBlNnxh62uE'
}, {
Expand Down
2 changes: 1 addition & 1 deletion modules/services/OsmService.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class OsmService extends AbstractSystem {
// Some defaults that we will replace with whatever we fetch from the OSM API capabilities result.
this._maxWayNodes = 2000;
this._imageryBlocklists = [/.*\.google(apis)?\..*\/(vt|kh)[\?\/].*([xyz]=.*){3}.*/];
this._urlroot = 'https://api.openstreetmap.org';
this._urlroot = 'https://www.openstreetmap.org';

this._tileCache = { toLoad: {}, loaded: {}, inflight: {}, seen: {}, rtree: new RBush() };
this._noteCache = { toLoad: {}, loaded: {}, inflight: {}, inflightPost: {}, note: {}, closed: {}, rtree: new RBush() };
Expand Down
30 changes: 15 additions & 15 deletions test/spec/services/OsmService.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ describe('OsmService', () => {

_osm = new Rapid.OsmService(new MockContext());
return _osm.initAsync()
.then(() => _osm.switchAsync({ url: 'https://api.openstreetmap.org' }));
.then(() => _osm.switchAsync({ url: 'https://www.openstreetmap.org' }));
});

afterEach(() => {
Expand All @@ -185,7 +185,7 @@ describe('OsmService', () => {

function loginAsync() {
return _osm.switchAsync({
url: 'https://api.openstreetmap.org',
url: 'https://www.openstreetmap.org',
client_id: 'O3g0mOUuA2WY5Fs826j5tP260qR3DDX7cIIE2R2WWSc',
client_secret: 'b4aeHD1cNeapPPQTrvpPoExqQRjybit6JBlNnxh62uE',
access_token: 'foo' // preauth
Expand Down Expand Up @@ -213,55 +213,55 @@ describe('OsmService', () => {

describe('#changesetURL', () => {
it('provides a changeset url', () => {
expect(_osm.changesetURL(2)).to.eql('https://api.openstreetmap.org/changeset/2');
expect(_osm.changesetURL(2)).to.eql('https://www.openstreetmap.org/changeset/2');
});
});

describe('#changesetsURL', () => {
it('provides a local changesets url', () => {
const center = [-74.65, 40.65];
const zoom = 17;
expect(_osm.changesetsURL(center, zoom)).to.eql('https://api.openstreetmap.org/history#map=17/40.65000/-74.65000');
expect(_osm.changesetsURL(center, zoom)).to.eql('https://www.openstreetmap.org/history#map=17/40.65000/-74.65000');
});
});

describe('#entityURL', () => {
it('provides an entity url for a node', () => {
const e = Rapid.osmNode({ id: 'n1' });
expect(_osm.entityURL(e)).to.eql('https://api.openstreetmap.org/node/1');
expect(_osm.entityURL(e)).to.eql('https://www.openstreetmap.org/node/1');
});

it('provides an entity url for a way', () => {
const e = Rapid.osmWay({ id: 'w1' });
expect(_osm.entityURL(e)).to.eql('https://api.openstreetmap.org/way/1');
expect(_osm.entityURL(e)).to.eql('https://www.openstreetmap.org/way/1');
});

it('provides an entity url for a relation', () => {
const e = Rapid.osmRelation({ id: 'r1' });
expect(_osm.entityURL(e)).to.eql('https://api.openstreetmap.org/relation/1');
expect(_osm.entityURL(e)).to.eql('https://www.openstreetmap.org/relation/1');
});
});

describe('#historyURL', () => {
it('provides a history url for a node', () => {
const e = Rapid.osmNode({ id: 'n1' });
expect(_osm.historyURL(e)).to.eql('https://api.openstreetmap.org/node/1/history');
expect(_osm.historyURL(e)).to.eql('https://www.openstreetmap.org/node/1/history');
});

it('provides a history url for a way', () => {
const e = Rapid.osmWay({ id: 'w1' });
expect(_osm.historyURL(e)).to.eql('https://api.openstreetmap.org/way/1/history');
expect(_osm.historyURL(e)).to.eql('https://www.openstreetmap.org/way/1/history');
});

it('provides a history url for a relation', () => {
const e = Rapid.osmRelation({ id: 'r1' });
expect(_osm.historyURL(e)).to.eql('https://api.openstreetmap.org/relation/1/history');
expect(_osm.historyURL(e)).to.eql('https://www.openstreetmap.org/relation/1/history');
});
});

describe('#userURL', () => {
it('provides a user url', () => {
expect(_osm.userURL('bob')).to.eql('https://api.openstreetmap.org/user/bob');
expect(_osm.userURL('bob')).to.eql('https://www.openstreetmap.org/user/bob');
});
});

Expand Down Expand Up @@ -721,17 +721,17 @@ describe('OsmService', () => {
<osm>
<note lon="10" lat="0">
<id>1</id>
<url>https://api.openstreetmap.org/api/0.6/notes/1</url>
<comment_url>https://api.openstreetmap.org/api/0.6/notes/1/comment</comment_url>
<close_url>https://api.openstreetmap.org/api/0.6/notes/1/close</close_url>
<url>https://www.openstreetmap.org/api/0.6/notes/1</url>
<comment_url>https://www.openstreetmap.org/api/0.6/notes/1/comment</comment_url>
<close_url>https://www.openstreetmap.org/api/0.6/notes/1/close</close_url>
<date_created>2019-01-01 00:00:00 UTC</date_created>
<status>open</status>
<comments>
<comment>
<date>2019-01-01 00:00:00 UTC</date>
<uid>584325</uid>
<user>bhousel</user>
<user_url>https://api.openstreetmap.org/user/bhousel</user_url>
<user_url>https://www.openstreetmap.org/user/bhousel</user_url>
<action>opened</action>
<text>This is a note</text>
<html>&lt;p&gt;This is a note&lt;/p&gt;</html>
Expand Down

0 comments on commit 4cc756d

Please sign in to comment.