• Hey hope I am not spamming here.

    When I use axios to hit /ping on the Write API with a GET I recieve a 200 as expected. But when I try to POST I get a 404. Any ideas? Do POST requests require https? Could nginx be messing this up?

    var token = my_token;
    
    function thisGetsA404(){
        var payload = JSON.stringify(
            {
                "property1": null,
                "property2": null
                }
            );
    
        axios
            .post('http://localhost/forum/ping', 
            payload,
                {
                headers: {
                    Authorization: `Bearer ${token}`
                    }
            })
            .then(res => {
                console.log(res.response)
            })
            .catch(error => {
                console.error(error)
            })
    }
    
    function thisGetsA200(){
        axios
            .get('http://localhost/forum/api/unread?_uid=2',{
                headers: {
                    Authorization: `Bearer ${token}`
                    }      
            })
            .then(res => {
                console.log(res)
            })
            .catch(error => {
                console.error(error)
            })
    }
    

  • Maybe something here?

      location /forum/ {
                if ($request_method = 'OPTIONS') {
                    add_header 'Access-Control-Allow-Origin' 'http://127.0.0.1*';
    
                    add_header 'Access-Control-Allow-Credentials' 'true';
                    add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
                    add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
                    add_header 'Access-Control-Max-Age' 1728000;
                    add_header 'Content-Type' 'text/plain charset=UTF-8';
                    add_header 'Content-Length' 0;
                    return 204;
                }
                if ($request_method = 'POST') {
                    add_header 'Access-Control-Allow-Origin' 'http://127.0.0.1*';
                    add_header 'Access-Control-Allow-Credentials' 'true';
                    add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
                    add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
                }
    
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header Host $http_host;
                proxy_set_header X-NginX-Proxy true;
    
                proxy_pass http://127.0.0.1:4567/;  # no subfolder defined here
                proxy_redirect off;
    
                # Socket.IO Support
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
    
    
            }
    

  • Hey all-

    I am a moron.

    I forgot the /api/v3 in the API url.

    fml

Suggested Topics

| |