vendredi 25 septembre 2020

AWS - call API services from frontend

Im building a website and I'm doing communication between backend and frontend with REST APIs. However, many of the endpoints exposed through this REST API will be selled to external clients, so I have built a ApiGateway with authorization through cognito to expose endpoints to external clients. Since this APIGateway will be consumed by external clients, this resource is public and is protected by a WAF and cloudfront distribution. How ever, my question is about comunication between backend and frontend since backend and front are in a private subnet, I have thought consume REST endpoints directly, by consume services using the application load balancer and not by the public apigateway because I think this will introduce ore complexity and latency (Apigateway is public). So, do you think this is good approach? (front end -backend comunication through the application load balancer without authorization beacuse are i a private subnet and i could control access using security groups and have a public api gateway only for external clients)

In the other hand, Im doing server side rendering in the first page load and nexts client side rendering. So I would like to know... how is the call of API in the client server rendering? request to the API is since client side to the front end and front end returns java script? or the html with contain endpoints of my bakend and send request direclty to my backend?,




Creating web card game for 4 players [closed]

I would like to make a web card game. Game should be for 4 players and it should wait for all players to connect and then start the game. Each player should see only his hand (not others hand), but all of them should see the same stack in the middle. My idea is that each player (when is on move) clicks on some card and that card will come to the middle where others will see it. There is specific order of players who is on a move.

I would like to write this game in python and then use some JavaScript probably.

I want to ask you what do you think is the easiest way to write this web app. I am struggling with the idea where should I write game's engine.

Friend of mine has suggested me to use Django but I don't think this will solve my problem.

As you probably noticed I am not very experienced in this stuff and that's why I am asking for an advice. Could you please give me an short advice how this all should be connected together and how should I continue?

Thank you for your answers.




if-else is not working in scss with react

I am working on this project of React with styling file .scss. And I want to implement this toggle and navbar that if I click it should change to open or vice-versa, but I am not getting whether the problem is with react or the if-else condition.

This is my react code:

import React, { useState } from 'react';
const Burger = () => {
const [open, setOpen] = useState(false)

return (
    <>
        <div className={styles['burger']} open={open} onClick={() => setOpen(!open)}>
            <div />
            <div />
            <div />
        </div>
        <RightNav open={open} />
    </>
)
}

And this is my .scss code:

 &:nth-child(1) {
  $type: open;
  @if $type == open {
    transform: rotate(45deg);
  } @else{
      transform: rotate(0);
  }
}
&:nth-child(2) {
  $type: open;
  @if $type == open {
    transform: translateX(100%);
    opacity: 0;
  } @else{
      transform: translateX(0);
      opacity: 1;
  }
}
&:nth-child(3) {
  $type: open;
  @if $type == open {
    transform: rotate(-45deg);
  } @else{
      transform: rotate(0);
  }
}

What does my code do? It runs and the navbar remains open and this code is for making the hamburger button and cross button. So, this is only staying in a cross button and on clicking the navbar stays open.




NGINX server unable to indent CSS tables

I'm on Namecheap VPS hosting enviroment. Running on ubuntu 18, latest Nginx, PHP and laravel.

I have tried several configuration by testing with etc/nginx/nginx.conf and etc/nginx/sites-available/domainname.com.conf after making changes reload the nginx, but nothing can seems to fix by problem.

nginx.conf

user www-data;
worker_processes 1;
pid /var/run/nginx.pid;

events {
    multi_accept       on;
    worker_connections 1024;
}

http {

    charset              utf-8;
    #sendfile             on;
    #tcp_nopush           on;
    #tcp_nodelay          on;
    #server_tokens        off;
    #log_not_found        off;
    #types_hash_max_size  2048;
    #client_max_body_size 16M;

    #include              mime.types;
    #default_type         application/octet-stream;

    access_log           /var/log/nginx/access.log;
    error_log            /var/log/nginx/error.log warn;

    ssl_session_timeout  1d;
    ssl_session_cache    shared:SSL:10m;
    ssl_session_tickets  off;

    # Diffie-Hellman parameter for DHE ciphersuites
    ssl_dhparam          /etc/letsencrypt/ssl-dhparams.pem;

    # Mozilla Intermediate configuration
    ssl_protocols        TLSv1.2 TLSv1.3;
    ssl_ciphers          ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;

    # OCSP Stapling
    ssl_stapling         on;
    ssl_stapling_verify  on;
    #resolver             1.1.1.1 1.0.0.1 8.8.8.8 8.8.4.4 208.67.222.222 208.67.220.220 valid=60s;
    resolver_timeout     2s;

    # Load configs
    #include              /etc/nginx/conf.d/*.conf;
    include              /etc/nginx/sites-enabled/*;
    #include         /etc/nginx/conf-enabled/*.conf;    
    
}

domainname.com.conf

upstream php-handler {
    server 127.0.0.1:9000;
    #server unix:/var/run/php/php7.2-fpm.sock;
}


server {
#   listen                  80;
#    listen                  [::]:80;
    listen                  443 ssl;
    listen                  [::]:443 ssl;
    server_name             domainname.com www.domainname.com;
    #set                     $base ;
    root                    /var/www/html/;

    # SSL
    ssl_certificate         /etc/letsencrypt/live/www.domainname.com/fullchain.pem;
    ssl_certificate_key     /etc/letsencrypt/live/www.domainname.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/www.domainname.com/chain.pem;

    # security
    include                 nginxconfig.io/security.conf;

    # logging
    access_log              /var/log/nginx/domainname.com.access.log;
    error_log               /var/log/nginx/domainname.com.error.log warn;

    # index.php
    index                   index.php index.html index.htm index.nginx-debian.html;

    # index.php fallback
    #location / {
    #    try_files $uri $uri/ /index.php?$query_string;
    #}

    # additional config
    include nginxconfig.io/general.conf;
    include nginxconfig.io/letsencrypt.conf;

    # handle .php (try_files syntax very important!)
    location ~ \.php$ {
    try_files $uri $uri/ /index.php?q=$uri&$args;
    fastcgi_pass  unix:/var/run/php/php7.2-fpm.sock;
    fastcgi_split_path_info ^(.+\.php)(/.+)$; #this line
    #fastcgi_pass   127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    include  /etc/nginx/mime.types;
    }
    location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
        try_files $uri /index.php$request_uri;
        add_header Cache-Control "public, max-age=15778463";
        # Add headers to serve security related headers (It is intended to
        # have those duplicated to the ones above)
        # Before enabling Strict-Transport-Security headers please read into
        # this topic first.
        #add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
        #
        # WARNING: Only add the preload option once you read about
        # the consequences in https://hstspreload.org/. This option
        # will add the domain to a hardcoded list that is shipped
        # in all major browsers and getting removed from this list
        # could take several months.
        add_header X-Content-Type-Options nosniff;
        add_header X-XSS-Protection "1; mode=block";
        add_header X-Robots-Tag none;
        add_header X-Download-Options noopen;
        add_header X-Permitted-Cross-Domain-Policies none;
        add_header Referrer-Policy no-referrer;

        # Optional: Don't log access to assets
        # access_log off;
    }    


}

# non-www, subdomains redirect
#server {
#    listen                  443 ssl;
#    listen                  [::]:443 ssl;
#    server_name             199.192.30.222;

    # SSL
    ssl_certificate         /etc/letsencrypt/live/www.domainname.com/fullchain.pem;
    ssl_certificate_key     /etc/letsencrypt/live/www.domainname.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/www.domainname.com/chain.pem;
#    return                  301 https://www.domainname.com$request_uri;
#}

I have PHP code that using CSS formatting to display web pages.

the web page menu title should display as a table for example:

column 1     column 2   column 3     column 4

but instead it is display as

column 1
column 2
column 3
column 4

I have check every logs, from the nginx, and laravel, there is no errors registered with this problem.

how should I go about this?

any help would be greatly appreciated.

Thanks Lica.




Unrecognized attribute 'xdt:Transform' in IIS

I hosted a web application in IIS and below is the web.config file for the application, but when i open the application i am getting following error Unrecognized attribute 'xdt:Transform'

`<?xml version="1.0" ?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
    <system.webServer xdt:Transform="InsertIfMissing">
        <rewrite xdt:Transform="InsertIfMissing">
            <rules xdt:Transform="InsertIfMissing">
              <rule name="index.html" stopProcessing="true">
                <match url=".*" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                  <add input="{REQUEST_FILENAME}" matchType="IsFile" pattern="" ignoreCase="true" negate="true" />
                </conditions>
                <action type="Rewrite" url="index.html" />
              </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>`

    



How can I export only a specific page in NextJS?

I want a build and export specific page in NextJS, how can I do it?

i.e. as a result I want to get only a specific HTML page in the "out" directory.




Requesting removal of stored website data from search engines

Greetings fellow developers,

I would like to ask for help regarding the following problem: Is there a way to request removal of stored website data from search engines? Most of the links that show up when searching my domain are old and non-existent.

What I've found from personal research regarding question/problem:

From my personal research I have found that removal requests can be made individually to the well-known search engines such as Google, Yahoo and Bing, but this is not what I am looking for, since I am well-aware that it would take a lot of time for the requests to be processed and the removal of the data to be done. Also, I wasn't able to find this "removal-request" webpage for the other (most) search engines.

To be more precise/clear...

... I want to request this website-data-removal to all (most) search engines at once, so that when I upload my new website (to the same domain), working and functional links (URLs) would be displayed. Can this be anyhow achieved and, if so, how? Also, how much time would it take for this removal to be finished?

Hope my question is clear enough, and any answer/help would be very much appreciated.