Hansi
09/15/2022, 5:20 PM/api/*
are forwarded to my Python Flask API, which is where the backend SuperTokens SDK is implemented.
As mentioned, it worked just before switching to nginx but now all requests to localhost:80/api/auth
and direct ones to the api localhost:8080/auth
all return the 404
from this function:
@app.route('/', defaults={'u_path': ''})
@app.route('/<path:u_path>')
def catch_all(u_path: str):
abort(404)
I am able to reach other API endpoints just fine through for example http://localhost/api/hello
.
nginx
server {
listen 80;
root /gg-host/build;
index index.html;
location / {
try_files $uri $uri/ =404;
add_header Cache-Control "no-cache";
}
location /static {
expires 1y;
add_header Cache-Control "public";
}
location /api {
include proxy_params;
proxy_pass http://api:8080;
}
}
Python Flask app_info
app_info=InputAppInfo(
app_name="GG-Host",
api_domain="http://localhost",
website_domain="http://localhost",
api_base_path="/api/auth",
website_base_path="/api/auth"
)
React app_info
appInfo: {
appName: "GG-Host",
apiDomain: "http://localhost",
websiteDomain: "http://localhost",
apiBasePath: "/api/auth",
websiteBasePath: "/api/auth"
}
rp_st
09/15/2022, 5:41 PMrp_st
09/15/2022, 5:43 PMapi_gateway_path
and set it to /api
. The value of api_base_path
should be set to /auth
.
The react config's apiBasePath should be /api/auth
and the webisteBasePath should be /auth
.rp_st
09/15/2022, 5:43 PMHansi
09/15/2022, 5:45 PMHansi
09/15/2022, 5:45 PMrp_st
09/15/2022, 5:46 PMrp_st
09/15/2022, 5:46 PMHansi
09/15/2022, 5:47 PM* Serving Flask app 'app' (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
WARNING:werkzeug: * Running on all addresses.
WARNING: This is a development server. Do not use it in a production deployment.
INFO:werkzeug: * Running on http://172.19.0.4:8080/ (Press CTRL+C to quit)
INFO:werkzeug:172.19.0.1 - - [15/Sep/2022 17:44:58] "GET /auth HTTP/1.1" 404 -
INFO:werkzeug:172.19.0.5 - - [15/Sep/2022 17:45:00] "GET /api/auth HTTP/1.0" 404 -
INFO:werkzeug:172.19.0.5 - - [15/Sep/2022 17:45:00] "GET /api/auth HTTP/1.0" 404 -
INFO:werkzeug:172.19.0.5 - - [15/Sep/2022 17:46:26] "GET /api/auth HTTP/1.0" 404 -
INFO:werkzeug:172.19.0.5 - - [15/Sep/2022 17:46:36] "GET /api/auth HTTP/1.0" 404 -
INFO:werkzeug:172.19.0.1 - - [15/Sep/2022 17:46:48] "GET /api/auth HTTP/1.1" 404 -
rp_st
09/15/2022, 5:50 PMrp_st
09/15/2022, 5:50 PMHansi
09/15/2022, 5:51 PM/api
with rewrite ^/api(.*)$ $1 break;
before forwarding the request to my Flask app?Hansi
09/15/2022, 5:51 PMrp_st
09/15/2022, 5:51 PMHansi
09/15/2022, 5:53 PM/auth
and no api gateway path?rp_st
09/15/2022, 5:53 PM/api
, then you need to add that as the api_gateway_pathHansi
09/15/2022, 6:00 PMCMD ["SUPERTOKENS_DEBUG=1", "python", "src/app.py"]
and also:
RUN export SUPERTOKENS_DEBUG=1
CMD ["python", "src/app.py"]
But neither seem to workrp_st
09/15/2022, 6:01 PMSUPERTOKENS_DEBUG=1
as an env variable to the python process - is that how you give env vars?Hansi
09/15/2022, 6:03 PMCMD ["SUPERTOKENS_DEBUG=1", "python", "src/app.py"]
in my Dockerfile would be equivalent to running SUPERTOKENS_DEBUG=1 python src/app.py
that doesn't seem to be the case. I will try something else.rp_st
09/15/2022, 6:03 PMHansi
09/15/2022, 6:06 PMHansi
09/15/2022, 6:07 PMrp_st
09/15/2022, 6:08 PM/auth
rp_st
09/15/2022, 6:08 PMHansi
09/15/2022, 6:08 PMHansi
09/15/2022, 6:08 PMrp_st
09/15/2022, 6:09 PMHansi
09/15/2022, 6:09 PMHansi
09/15/2022, 6:09 PMrp_st
09/15/2022, 6:10 PM/api/auth
for api base pathrp_st
09/15/2022, 6:10 PM/auth
for api base pathHansi
09/15/2022, 6:12 PMHansi
09/15/2022, 6:13 PMhttp://localhost/api/auth
rp_st
09/15/2022, 6:13 PMrp_st
09/15/2022, 6:14 PMrp_st
09/15/2022, 6:14 PMHansi
09/15/2022, 6:14 PMrp_st
09/15/2022, 6:15 PMrp_st
09/15/2022, 6:15 PMHansi
09/15/2022, 6:15 PMhttp://localhost/api/auth
not display the login form? π€rp_st
09/15/2022, 6:16 PMrp_st
09/15/2022, 6:16 PMHansi
09/15/2022, 6:16 PMrp_st
09/15/2022, 6:16 PMHansi
09/15/2022, 6:17 PMrp_st
09/15/2022, 6:17 PM/
route?rp_st
09/15/2022, 6:17 PMHansi
09/15/2022, 6:18 PMserver {
listen 80;
root /gg-host/build;
index index.html;
location / {
try_files $uri $uri/ =404;
add_header Cache-Control "no-cache";
}
location /static {
expires 1y;
add_header Cache-Control "public";
}
location /api {
include proxy_params;
proxy_pass http://api:8080;
}
}
rp_st
09/15/2022, 6:19 PMrp_st
09/15/2022, 6:19 PMHansi
09/15/2022, 6:20 PMlocation /auth {
try_files index.html =404;
}
rp_st
09/15/2022, 6:21 PMrp_st
09/15/2022, 6:21 PMrp_st
09/15/2022, 6:21 PM/
on the /auth
and /auth/*
route as well (assuming that the websiteBasePath value is /auth
)rp_st
09/15/2022, 6:22 PMHansi
09/15/2022, 6:23 PMrp_st
09/15/2022, 6:23 PMHansi
09/15/2022, 6:27 PMhttp://localhost/auth
location /auth {
try_files /index.html =404;
}
Can you think of a way I could test for http://localhost/auth/*
?rp_st
09/15/2022, 6:29 PMrp_st
09/15/2022, 6:29 PMHansi
09/15/2022, 6:29 PMHansi
09/15/2022, 6:29 PMrp_st
09/15/2022, 6:29 PMrp_st
09/15/2022, 6:30 PMHansi
09/15/2022, 6:31 PMrp_st
09/15/2022, 6:31 PM