Skip to content
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

backend receiving wrong http scheme #308

Open
kwatog opened this issue Nov 8, 2020 · 3 comments
Open

backend receiving wrong http scheme #308

kwatog opened this issue Nov 8, 2020 · 3 comments

Comments

@kwatog
Copy link

kwatog commented Nov 8, 2020

Request is receiving http instead of https. I think it's due to some settings in the traefik dockerfile but I can't figure which setting is causing this. Here's part of the docker-compose file.

      labels:
        # Enable Traefik for this service, to make it available in the public network
        - traefik.enable=true
        # Use the traefik-public network (declared below)
        - traefik.docker.network=${TRAEFIK_PUBLIC_NETWORK?Variable not set}
        # Use the custom label "traefik.constraint-label=traefik-public"
        # This public Traefik will only use services with this label
        - traefik.constraint-label=${TRAEFIK_PUBLIC_TAG?Variable not set}
        # traefik-http set up only to use the middleware to redirect to https
        - traefik.http.middlewares.${STACK_NAME?Variable not set}-https-redirect.redirectscheme.scheme=https
        - traefik.http.middlewares.${STACK_NAME?Variable not set}-https-redirect.redirectscheme.permanent=true
        # Handle host with and without "www" to redirect to only one of them
        # Uses environment variable DOMAIN
        # To disable www redirection remove the Host() you want to discard, here and
        # below for HTTPS
        - traefik.http.routers.${STACK_NAME?Variable not set}-proxy-http.rule=Host(`${DOMAIN?Variable not set}`) || Host(`www.${DOMAIN?Variable not set}`)
        - traefik.http.routers.${STACK_NAME?Variable not set}-proxy-http.entrypoints=http
        # traefik-https the actual router using HTTPS
        - traefik.http.routers.${STACK_NAME?Variable not set}-proxy-https.rule=Host(`${DOMAIN?Variable not set}`) || Host(`www.${DOMAIN?Variable not set}`)
        - traefik.http.routers.${STACK_NAME?Variable not set}-proxy-https.entrypoints=https
        - traefik.http.routers.${STACK_NAME?Variable not set}-proxy-https.tls=true
        # Use the "le" (Let's Encrypt) resolver created below
        - traefik.http.routers.${STACK_NAME?Variable not set}-proxy-https.tls.certresolver=le

@btoro
Copy link

btoro commented Feb 1, 2021

Did you ever figure this out? I think im having a similar issue. I'm receiving the following response when I make an API call to the backend, even though I direct it to https:

Mixed Content: The page at 'https://XXX' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://XXXX'. This request has been blocked; the content must be served over HTTPS.

For some reason it switches the call to http

I also noticed that navigating to http doesn't auto redirect to https

@kwatog
Copy link
Author

kwatog commented Feb 10, 2021

unfortunately, no. I exactly have the same problem with you. I initially fixed this by replacing http:// with https:// in the client (vuejs). but since I only needed that for my images that I have since moved to firebase storage, I don't have a use for it.

So the issue remains. The solutions I made are workarounds.

@Kangonaut
Copy link

I experienced the same problem and after some trying finally found a "solution".
The problem didn't occur on every route, only specific API endpoints seemed to be broken. So after some investigation, I found out that only requests that used query parameters seemed to fail. However, the api/v1/items/?skip=0&limit=10 endpoint still worked fine. Looking at the code in the ItemService class that issues the request, the URL /api/v1/items/ ends with a /, which sadly seems to be the only reason why my custom requests failed. After adding that missing trailing / char, it all worked fine. I know this isn't really a solution, but at least it's an easy fix.

public static readItems(data: TDataReadItems = {}): CancelablePromise<ItemsPublic> {
    const {
        limit = 100,
        skip = 0,
    } = data;
    return __request(OpenAPI, {
        method: 'GET',
        url: '/api/v1/items/',
        query: {
            skip, limit
        },
        errors: {
            422: `Validation Error`,
        },
    });
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants