GCP App Engine unable to serve resource files like JavaScript - google-app-engine

I have hosted my dotnetcore 2.0 app on GCP App Engine with my app.yaml as follows.
runtime: aspnetcore
env: flex
manual_scaling:
instances: 1
resources:
cpu: 1
memory_gb: 0.5
disk_size_gb: 10
endpoints_api_service:
name: ***********
rollout_strategy: managed
My API's work fine, but when I try to load a cshtml view with resources pointing to wwwroot, I get an error loading resources (ex: .js , .css)
{
"code": 5,
"message": "Method does not exist.",
"details": [
{
"#type": "type.googleapis.com/google.rpc.DebugInfo",
"stackEntries": [],
"detail": "service_control"
}
]
}
My purpose here is to have an dotnetcore app serving web API's as well as an Angular6 UI SPA.

Related

CORS issue in micro frontend repo

Context: I'm working in a monorepo, I've setup architecture using NX. I've been trying to build micro frontend apps and I've managed to do so using module federation on local environment. For that purpose I've to start both of my apps locally. So host app runs at http://localhost:4200/ which can load my remote app which is running on http://localhost:4201/
Question
Now I wants to load my remote app where it is hosted (it's hosted on S3 bucket as a static web) instead of my localhost, but I'm getting CORS issue even though I've defined rule for that on my S3 bucket to allow cross origin.
Any help would be much appreciated.
Attaching screenshot of my error below:
I've defined CORS policy as below snippet:
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"HEAD"
],
"AllowedOrigins": [
"http://localhost:4200/"
],
"ExposeHeaders": []
}
]

How to use a docker image from Artifactory on Google App Engine?

How to deploy a docker image from Artifactory on Google App Engine?
What I am trying to achieve is deploying my docker image that is stored on a jfrog Artifactory to a Good App Engine. Though all the examples I find are pushing the image to Artifact Registry which is redundant as I only want to store the artifact on jfrog. Has anyone tried to do it before?
Here is the further I could go using Cloud Build:
- name: 'gcr.io/cloud-builders/docker'
dir: /workspace/app
args: [ 'pull', 'myjfrogurl.jfrog.io/$PROJECT_ID:$BRANCH_NAME' ]
Then I use terraform later to deploy:
resource "google_app_engine_flexible_app_version" "app_deploy" {
version_id = "v1"
service = var.service_name
runtime = "nodejs"
...
deployment {
container {
# Here is the problem as it needs to be a google URI
image = "myjfrogurl.jfrog.io/${var.project_id}:${var.branch_name}"
}
}
Maybe there is a way of doing that, it doesn't need to be via terraform or cloud build.
Edit
With the following code is possible to pull the image from jfrog and push to Container Registry where it will be visible for App Engine or Cloud Run, though as the answer says it is not possible to keep the image stored in only one place
# Pull from external repository
- name: 'gcr.io/cloud-builders/docker'
args: [ 'pull', 'myjfrogurl.jfrog.io/$PROJECT_ID:$BRANCH_NAME' ]
# Do a fast build using --cache-from
- name: 'gcr.io/cloud-builders/docker'
args: [ 'build',
'-t', 'gcr.io/$PROJECT_ID/appName:$BRANCH_NAME',
'--cache-from', 'gcr.io/$PROJECT_ID/appName:$BRANCH_NAME',
'.' ]
# Tag the image for Container Registry
- name: 'gcr.io/cloud-builders/docker'
args: ['tag',
'gcr.io/$PROJECT_ID/appName:$BRANCH_NAME']
# Push to the Container Registry
- name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/$PROJECT_ID/appName:$BRANCH_NAME']
Posting Guillaume Blaquiere's comment as a Community Wiki answer for better visibility for the community:
This is not possible for App Engine, and there is the same limitation with Cloud Run.
To deploy an image to the App Engine it requires to push the image to the Google Container Registry. Under the hood container registry is a GCP bucket called eu.artifacts.projectId.appspot.com or artifacts.projectId.appspot.com (according to the region - more). Artifacty Registry is a service under the Container Registry to help managing the images.

Firebase hosting rewrite for external wordpress under /blog path

I'm working on a React app hosted on Firebase, and a Wordpress blog hosted on Godaddy.
Is it possible to have the Wordpress blog rendering under /blog ?
I tried something like this in firebase.json (handeling multiple targets):
"hosting": [
{
"target": "site1",
"public": "site1/public",
"rewrites": [
{
"source": "/blog/**",
"destination": "myblog.example.com"
}
]
},
...
]
But I'm getting the 404 page from the React app.
I know I can rewrite to a Cloud Function, but how to "proxy" to the external blog, preventing the app to "catch" the request ?
You can't rewrite to arbitrary URLs -- to accomplish this you'd need to deploy a Cloud Function that proxied to the Wordpress blog using e.g. node-http-proxy. You could also use Cloud Run to host the Wordpress blog directly and rewrite to the Cloud Run service.

how to authenticate jhipster ionic login

I am trying to create an ionic app, This app uses a jhipster created web-app as intranet with HTTP session authentication.
How should i authenticate user in ionic app who is already created in jhipster.
JHipster configuration, a .yo-rc.json file generated in the root folder
{
"generator-jhipster": {
"jhipsterVersion": "3.0.0",
"baseName": "vconnect",
"packageName": "com.zenfact.vconnect",
"packageFolder": "com/zenfact/vconnect",
"serverPort": "8080",
"authenticationType": "session",
"hibernateCache": "ehcache",
"clusteredHttpSession": "no",
"websocket": "no",
"databaseType": "sql",
"devDatabaseType": "postgresql",
"prodDatabaseType": "postgresql",
"searchEngine": "elasticsearch",
"buildTool": "maven",
"enableSocialSignIn": false,
"rememberMeKey": "559bbe3167552d040ba24d16506d389a7ba851c3",
"useSass": false,
"applicationType": "monolith",
"testFrameworks": [
"gatling"
],
"enableTranslation": true,
"nativeLanguage": "en",
"languages": [
"en",
"zh-cn",
"fr",
"hi",
"ja"
]
}
}
I did some digging around and found that mobile apps are not a big fan of cookies.
Thus have decided to recreate the jhipster application to either oauth or JWT
Note:
Jhipster has 3 authentication method JWT, Oauth2 and HTTP session.
I initially started with a Jhipster project with HTTP session.
I was separately creating a ionic app project which was supposed to consume
the rest call of this jhipster application.
Long story short after some trial and error I came to realization to just recreate the ionic app with either JWT or Oauth2 authentication.

Google App Engine: Disable favicon.ico

I have a Google App Engine project running PHP 5.5. This is my app.yaml:
application: example
version: 1
runtime: php55
api_version: 1
threadsafe: true
handlers:
- url: .*
script: main.php
All requests go to main.php. My app only sends data for an Android application and thus doesn't need to display a favicon.ico. But if I call my application in my browser (Chrome) and consult the app logs afterwards there is a request to favicon.ico. How can I disable this or how can I tell App Engine to NOT SERVE a favicon?
EDIT: I can't just send some HTML to prevent the loading of the favicon, because I need to send JSON data to my application in which I can't include HTML.

Resources