logo
Tags down

shadow

How do i link a JAVA 8 backend to an Angular frontend?


By : Terje
Date : October 18 2020, 06:10 AM


Share : facebook icon twitter icon

Google App Engine - Java-backend and Angular-frontend in a single project


By : photisss
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further The answer to both questions is yes. The client and server code can be developed using IntelliJ Ultimate edition in the same project folder.
In my GAE project I'm using Python rather than Java, but the setup for Java could be nearly identical.
code :
+-- .idea
|
+-- dist
|
+-- node_modules
|
+-- src
   |
   +-- app
   |  |
   |  +-- app.module.ts
   |
   +-- server
   |  |
   |  +-- <Python code>  // Or your Java code
   |
   +-- tools
   |
   \-- index.html
cd dist_prod && gcloud app deploy -v v1 --project api-project-######## --verbosity debug

Java backend + Angular 2 (or higher) frontend


By : Nicholas Haynes
Date : March 29 2020, 07:55 AM
Any of those help It's an architecture decision. There is no simple right or wrong here. There are pro and cons for both designs.
If you separate frontend and backend you have a clearer separation of concerns. You could let some people work only for the backend or only for the frontend side. You could define a build and deploy pipeline for frontend purpose and one for the backend side. Which is easier to understand and maintain as a mixed one. In such an approach you should define a clear api between frontend and backend. So, that both projects can be build separately as long as the api definition does not change. You could build tests against this api and mock services to launch the one side without the other (for development). For a microservice landscape, the separated design would normally be a better match.

Download file with Angular frontend from Java backend


By : Utkarsh
Date : March 29 2020, 07:55 AM
I wish this help you I don't work with Java so I can't comment on whether your data coming from the server is correct. But in my Angular project I used the "file-saver" library off npm to trigger saving a PDF sent from my server. Then in my Angular code something to the effect of:
code :
import * as FileSaver from 'file-saver';

downloadPDF() {
    this.http.get("api/endpoint/address", {withCredentials: true, responseType: "blob"}).subscribe(r => {
      var blob = r;
      FileSaver.saveAs(blob, "Filename.pdf");
    });
}

yii2 - frontend to backend and backend to frontend controller config files + .htaccess - COMPLETLY CONFIGURATION


By : thepbac thep
Date : March 29 2020, 07:55 AM
this one helps. Finally it's done ! On the fresh yii2 advanced i set up connections between frontend and backend, but still have a problem with pretty url in both "sides".
backend/.htaccess
code :
RewriteEngine on

#if directory or a file exist, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#otherwise, forward to index.php
RewriteRule . index.php
use \yii\web\Request;
$baseUrl = str_replace('/backend/web', '/backend/web', (new Request)->getBaseUrl());
$frontEndBaseUrl = str_replace('/backend/web', '/frontend/web', (new Request)->getBaseUrl());

$params = array_merge(
    require __DIR__ . '/../../common/config/params.php',
    require __DIR__ . '/../../common/config/params-local.php',
    require __DIR__ . '/params.php',
    require __DIR__ . '/params-local.php'
);

return [
    'id' => 'app-backend',
    'basePath' => dirname(__DIR__),
    'controllerNamespace' => 'backend\controllers',
    'bootstrap' => ['log'],
    'modules' => [],
    'components' => [
        'request' => [
            'csrfParam' => '_csrf-backend',
        ],

'user' => [
            'identityClass' => 'common\models\User',
            'enableAutoLogin' => true,
            'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],
        ],

        'session' => [
            // this is the name of the session cookie used for login on the backend
            'name' => 'advanced-backend',
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],


// main - used to generate and parse URLs to backend from backend app
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'baseUrl' => '/backend/web',
        ],
// slave - used to generate URLs to frontend from backend app
        'urlManagerFrontend' => [
            'class' => 'yii\web\urlManager',
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'baseUrl' => '/',
            'rules' => [
                '/' => 'site/index',
                'home' => 'site/home',
                'about' => 'site/about',
                'moje-prace' => 'site/moje-prace',
                'umow-wizyte' => 'rezerwacje/create',
                'contact' => 'site/contact',
                'login' => 'site/login',
                'signup' => 'site/signup',
            ],
        ],
    ],
    'params' => $params,
];
$frontendUrl= Yii::$app->urlManagerFrontend->createUrl('//');
echo yii\helpers\Html::a('link to frontend', $frontendUrl);
RewriteEngine on

#if directory or a file exist, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#otherwise, forward to index.php
RewriteRule . index.php
use \yii\web\Request;
$baseUrl = str_replace('/frontend/web', '/frontend/web', (new Request)->getBaseUrl());
$backEndBaseUrl = str_replace('/frontend/web', '/backend/web', (new Request)->getBaseUrl());


$params = array_merge(
    require __DIR__ . '/../../common/config/params.php',
    require __DIR__ . '/../../common/config/params-local.php',
    require __DIR__ . '/params.php',
    require __DIR__ . '/params-local.php'
);

return [
    'id' => 'app-frontend',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'controllerNamespace' => 'frontend\controllers',
    'components' => [
        'request' => [
            'csrfParam' => '_csrf-frontend',
        ],
        'user' => [
            'identityClass' => 'common\models\User',
            'enableAutoLogin' => true,
            'identityCookie' => ['name' => '_identity-frontend', 'httpOnly' => true],
        ],
        'session' => [
            // this is the name of the session cookie used for login on the frontend
            'name' => 'advanced-frontend',
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],

// main - used to generate and parse URLs to frontend from frontend app
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'baseUrl' => $baseUrl,
            'rules' => [
                '/' => 'site/index',
                '/home' => 'site/home',
                '/about' => 'site/about',
                'moje-prace' => 'site/moje-prace',
                'umow-wizyte' => 'rezerwacje/create',
                'contact' => 'site/contact',
                'login' => 'site/login',
                'signup' => '/site/signup',
            ],
        ],
// slave - used to generate URLs to backend from frontend app
        'urlManagerBackend' => [
            'class' => 'yii\web\urlManager',
            'baseUrl' => $backEndBaseUrl,
            'enablePrettyUrl' => false,
            'showScriptName' => false,
        ],

    ],
    'params' => $params,
];
$backendUrl= Yii::$app->urlManagerBackend->createUrl('//');
echo yii\helpers\Html::a('link to backend', $backendUrl);
header("Location: http://pp.test/frontend/web/", true, 301);
exit();

django backend and angular frontend send request to backend


By : user2460174
Date : March 29 2020, 07:55 AM
like below fixes the issue If you setup a proxy, you can just write the urls as /api, all calls of http://localhost:4200/api will be diverted to http://localhost:3000/api.
From angular docs:
code :
{
  "/api": {
    "target": "http://localhost:3000",
    "secure": false
  }
}
...
"architect": {
  "serve": {
    "builder": "@angular-devkit/build-angular:dev-server",
    "options": {
      "browserTarget": "your-application-name:build",
      "proxyConfig": "src/proxy.conf.json"
    },
...
Related Posts Related Posts :
  • How to modify camel Exchange and send it
  • How do I avoid constructors?
  • Passing string in where clause using PreparedStatement
  • Tomcat 7 - Ignoring db conections pool parameters (DBCP)
  • How does reduce() method work with parallel streams in Java 8?
  • How can I use a generic class with wildcard declaration?
  • Unable to add ArrayList with multiple arguments
  • Move application into second window monitor in javafx
  • does intern() method have implication on performance?
  • How to run NPM Command in Java code using ProcessBuilder
  • Sending HTTP/2 request via Socket in Java
  • eclipse IDE wrong warning that unused field
  • Decode Java enum from single char
  • How to hide embedded dependencies when using an OSGI bundle with maven?
  • How to correctly implement a generic interface in Java
  • send alert to html page from servlet
  • <EOF>Exception while creating Derby table
  • What does stack.pop() return?
  • Problem with Java Language Levels in IntelliJ IDEA
  • How do i get the status code for a response i subscribe to using the JDK's HttpClient?
  • How should my INSERT INTO statement for GENERATED BY DEFAULT AS IDENTITY be?
  • What is a good way to allow only one non null field in an object
  • Java Runtime only recognizes class file versions up to 52.0 even when java 11 is installed
  • For loop an arraylist for each first two elements separated by comma in Java
  • Filter values from a list based on priority
  • In java, how can i declare a variable inside an if lambda condition?
  • How to XOR a String using a byte array as key?
  • Print Statement in Loop Repeats Multiple Times
  • Generating unique value in java give duplicate
  • How to fix 'handleWindowVisibility: no activity for token android.os.BinderProxy'?
  • Memory issue - InputStream/OutputStream
  • Download a .csv file Java6
  • Why NavigableSet JavaDoc states about implementation details?
  • How to create health check in Grafana?
  • What is the optimal way to call N blocking api calls in parallel to get most out of CPU while waiting for api calls to c
  • How to control text in edittext after key is pressed?
  • NullPointerException when starting a Popupwindow with default values set, otherwise it works
  • How to filter a dataset according to datetime values in Spark
  • RegEx for matching commas inside array values
  • Program won't continue when pressing enter. How do I fix this error?
  • Trying to increment counter using character comparison
  • Convert list into String with values
  • Avoiding major/minor version conflicts with Java/Maven dependencies
  • Lag a value with Datavec transform
  • Lower bound generic in java does not compile even when passing super class
  • Why CompletableFuture.runAsync is not executed?
  • How can I make the ball go where it is supposed to go after it is hit by the stick?
  • Spring -- allow overriding THAT particular bean only
  • Can i mock file.mkdirs() which is inside of a method
  • How to get .crt file from .jks
  • How to remove characters from String Value?
  • Unit Testing a Public method with private supporting methods inside of it?
  • JavaFX when button press draw rectangle with dimensions in textField and find if they intersect
  • pushing to hashmap of lists
  • Execution failed for task ':app:transformClassesAndResourcesWithR8ForRelease' while generating signed apk/bundle
  • log4j2 generates folder with older date - Springboot
  • Java casting mystery - Class.cast vs cast operator
  • Android sending notification from application A to application B
  • Libgdx Clearing Screen benefits
  • Asynchronous Lambda Proxy integration
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk