terraform-aws-serverless-pypi
terraform-aws-serverless-pypi copied to clipboard
index.html anchors missing /simple stage
Using the configuration in the readme the index.html is served at hostname/simple
and packages are served at hostname/simple/packagename
. Both these two things work, however the index.html served at /simple
links to packages without the /simple
stage in the url, instead going to hostname/packagename
, which does not exist, resulting in a 403 forbidden error when clicked.
thanks for reporting. Must be a related to the switch from HTTP to REST API.
Hm, I am having trouble replicating this. I deployed the code in /example
which essentially matches the README and here is what I get:
curl -s https://{api-id}.execute-api.us-west-2.amazonaws.com/simple/ | prettier --parser html
<!doctype html>
<html>
<head>
<meta name="pypi:repository-version" content="1.0" />
<title>Simple index</title>
</head>
<body>
<h1>Simple index</h1>
<a href="requests-iamauth">requests-iamauth</a><br />
</body>
</html>
The href points to a relative path, requests-iamauth
, so clicking it should bring me to https://{api-id}.execute-api.us-west-2.amazonaws.com/simple/requests-iamauth
.
Could you paste the HTML code from your index.html and the URL you use to access it (feel free to redact the host)
Thanks for getting back so fast!
Heres the source of our index.html
curl -s 'https://pypi.company.com/simple' | prettier --parser=html
<!doctype html>
<html>
<head>
<meta name="pypi:repository-version" content="1.0" />
<title>Simple index</title>
</head>
<body>
<h1>Simple index</h1>
<a href="apilib">apilib</a><br /><a href="chalice">chalice</a><br /><a
href="django-allauth"
>django-allauth</a
><br /><a href="peewee">peewee</a><br /><a href="pyrtemis">pyrtemis</a
><br /><a href="skapi">skapi</a><br /><a href="stacklib">stacklib</a><br />
</body>
</html>
And we access it at https://pypi.company.com/simple
(aws_api_gateway_domain_name and aws_api_gateway_base_path_mapping for the domain configured with terraform)
Clicking one of the links on the page (eg peewee) will take us to https://pypi.company.com/peewee
, rather than the correct location of https://pypi.company.com/simple/peewee
I wonder if this is a browser issue. Which browser are you using?
Does pip download
work for any of these links?
eg,
pip download --no-deps --index-url https://<host>/simple/ <package>
Seems to occur across different browsers, both firefox and chromium. The pip download command looks like it worked as expected, and using the index in pip generally works, its just the web index that isn't working right
I cannot seem to recreate this issue. I just pushed an update to the example using a custom domain name and base path mapping but it's all working fine for me on Safari and Chromium (Arc).
Could you try manually updating your index.html to add a ./
prefix to the hrefs, push it back up to S3 and try again?
Eg,
aws s3 cp s3://your-pypi-bucket/index.html .
# edit index.html hrefs
aws s3 cp index.html s3://your-pypi-bucket/index.html
I am having exactly the same issue. Manually adding ./
prefix does not work. Adding simple/
prefix does
Can I see the module hcl?
module "pypi" { source = "amancevice/serverless-pypi/aws" version = "~> 7"
api_execution_arn = aws_api_gateway_rest_api.pypi.execution_arn api_id = aws_api_gateway_rest_api.pypi.id api_root_resource_id = aws_api_gateway_rest_api.pypi.root_resource_id event_rule_name = "pypi-reindex" iam_role_name = "pypi" lambda_api_fallback_index_url = "https://pypi.org/simple/" lambda_api_function_name = "pypi-api" lambda_reindex_function_name = "pypi-reindex" lambda_reindex_timeout = 14 log_group_api_retention_in_days = 14 log_group_reindex_retention_in_days = 14 s3_bucket_name = "******" }