Comments (5)
@DanielMaierLGLN I think this is expected, It's let to the end users to customize
the application layer.
Basically you need to update https://github.com/stac-utils/stac-fastapi/blob/master/stac_fastapi/sqlalchemy/stac_fastapi/sqlalchemy/app.py#L31 as 👇
"""FastAPI application."""
from stac_fastapi.api.app import StacApi
from stac_fastapi.extensions.core import (
FieldsExtension,
QueryExtension,
SortExtension,
TransactionExtension,
)
from stac_fastapi.extensions.third_party import BulkTransactionExtension
from stac_fastapi.sqlalchemy.config import SqlalchemySettings
from stac_fastapi.sqlalchemy.core import CoreCrudClient
from stac_fastapi.sqlalchemy.session import Session
from stac_fastapi.sqlalchemy.transactions import (
BulkTransactionsClient,
TransactionsClient,
)
from starlette.middleware.cors import CORSMiddleware
settings = SqlalchemySettings()
session = Session.create_from_settings(settings)
api = StacApi(
settings=settings,
extensions=[
TransactionExtension(client=TransactionsClient(session=session)),
BulkTransactionExtension(client=BulkTransactionsClient(session=session)),
FieldsExtension(),
QueryExtension(),
SortExtension(),
],
client=CoreCrudClient(session=session),
)
app = api.app
# ADD CORSMiddleware
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["GET", "POST"],
allow_headers=["*"],
)
from stac-fastapi.
Thank you very much @vincentsarago!
If it is expected to be done by the end users - it's ok for me (maybe it makes sense it include it in the documentation?).
I confirm that your solution is working (apart from a small typo in the app.add_middleware part).
Thanks again :)
from stac-fastapi.
Given the api spec recommends adding CORS I think it makes sense to include by default.
https://github.com/radiantearth/stac-api-spec/blob/master/implementation.md#cors
from stac-fastapi.
Linking to the FastAPI CORS docs would be lovely https://fastapi.tiangolo.com/tutorial/cors/
from stac-fastapi.
Closed with #436
from stac-fastapi.
Related Issues (20)
- Collection update endpoint
- Upgrade fastapi version for Content-Type Header ReDoS HOT 1
- INFERRED_LINK_RELS is missing `items` links? HOT 1
- Datetime as null is not accepted by the STAC FASTAPI HOT 8
- Aliases in FilterExtensionGetRequest model are not working
- Simple search returns items onlly with properties.datetime field HOT 3
- Becoming a maintainer on this project HOT 5
- Examine if pr 442 introduces breaking changes HOT 2
- Document new enhanced middleware configuration options
- Cannot use custom fields in Items HOT 9
- Introduce a tool to bump all version strings across project before release
- Deprecate Context Extension module
- PUT "/collections/{collection_id}" throws "update_collection() missing 1 required positional argument: 'collection'" HOT 3
- Integration testing with key stac-fastapi backends HOT 5
- pin sub-modules (api/extensions) to specific version HOT 4
- Detect disabled extensions in requests HOT 2
- types in `BaseSearchGetRequest`?
- How to tell if search is for single datetime? (Should `str_to_interval` return a single value for that?) HOT 7
- Remove pystac HOT 1
- Authentication and authorization implementation HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stac-fastapi.