-
Notifications
You must be signed in to change notification settings - Fork 42
Fix dependencies issues shapely/MVT and free localost from osmose.openstreetmap.fr #540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import os | ||
|
|
||
| from fastapi import Depends, FastAPI, HTTPException, Request, Response, responses | ||
| from fastapi.middleware.cors import CORSMiddleware | ||
|
|
||
| from api import app as api | ||
| from control import app as control | ||
|
|
@@ -11,6 +12,23 @@ | |
|
|
||
| app = FastAPI() | ||
|
|
||
| origins = [ | ||
| "https://osmose.openstreetmap.fr", | ||
| "http://localhost", | ||
| "http://localhost:8080", | ||
| "http://localhost:20009", | ||
| "http://127.0.0.1", | ||
| "http://127.0.0.1:8080", | ||
| "http://127.0.0.1:20009" | ||
| ] | ||
|
|
||
| app.add_middleware( | ||
| CORSMiddleware, | ||
| allow_origins=origins, | ||
| allow_credentials=True, | ||
| allow_methods=["*"], | ||
| allow_headers=["*"], | ||
| ) | ||
|
|
||
| @app.on_event("startup") | ||
| async def startup(): | ||
|
|
@@ -58,6 +76,16 @@ def sprite_png(): | |
| return Response(open("web_api/public/assets/sprite.png", "rb").read()) | ||
|
|
||
|
|
||
| @app.get("/assets/marker-gl-sprite.json") | ||
| def sprite_png(): | ||
| return Response(open("web_api/public/assets/marker-gl-sprite.json", "rb").read()) | ||
|
|
||
|
|
||
| @app.get("/assets/marker-gl-sprite.png") | ||
| def sprite_png(): | ||
| return Response(open("web_api/public/assets/marker-gl-sprite.png", "rb").read()) | ||
|
|
||
|
|
||
|
||
| @app.get("/images/markers/{filename:path}.png") | ||
| def marker(filename): | ||
| file_path = f"web_api/static/images/markers/{filename}.png" | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ module.exports = (env, argv) => { | |
| }, | ||
| plugins: [ | ||
| new SpritezeroWebpackPlugin({ | ||
| source: '../web_api/static/images/**/*.svg', | ||
| source: 'images/**/*.svg', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May you need this, because you de not run it from the right path ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I run this from the docker-compose, in the osmose-frontend/docker directory docker-compose -f docker-compose.yml -f docker-compose-test.yml up And it didn't work unless I make the path relative to the config file (which is already in web_api/static) |
||
| output: 'marker-gl-', | ||
| }) | ||
| ], | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CORS on non public API are on purpose.
I'm OK for CORS as middleware, but only for API. Host can be *.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may find more appropriate strategy for origins (I choose the default one).
But I was unable to get https://osmose.openstreetmap.fr/assets/marker-gl-sprite.png from localhost:8080 when opening the map in my browser.
localhost should rely on localhost resources only and we may adjust appropriate origins depending on env prod/dev
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed @frodrigo, I didn't understand properly the nesting with FastAPI.
I've specified more appropriate CORS for web assets only, and preserving the existing CORS for everything else.