Maillol / aiohttp-pydantic

Aiohttp View that validates request body and query sting regarding the annotations declared in the View method
MIT License
67 stars 21 forks source link

Fix/relative static path #38

Closed steersbob closed 2 years ago

steersbob commented 2 years ago

Problem

The OAS page template is initialized with fully qualified URLs that include protocol (http/https). This assumption is invalid when the app is placed behind a reverse proxy that handles SSL termination. The app requests static files over http while the browser has requested a https page.

Implementation

The static_url and openapi_spec_url variables used in template initialization are changed to be paths relative to the root.

Previously: http://host.com:8080/parent_app_prefix/oas/static Now: /parent_app_prefix/oas/static

To retain the initial / in the path, the static_url trim is removed from index.j2.

codecov-commenter commented 2 years ago

Codecov Report

Merging #38 (6935c92) into main (69fb553) will increase coverage by 0.36%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #38      +/-   ##
==========================================
+ Coverage   93.15%   93.51%   +0.36%     
==========================================
  Files          11       11              
  Lines         774      771       -3     
==========================================
  Hits          721      721              
+ Misses         53       50       -3     
Impacted Files Coverage Δ
aiohttp_pydantic/oas/view.py 97.19% <100.00%> (+2.65%) :arrow_up:

:mega: Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

Maillol commented 2 years ago

In fact if your application is placed behind a proxy, you should use your proxy to serve the swager UI and the oas as static content. You can generate the the oas file using the command "python -m aiohttp_pydantic.oas".