Heroku deployment issue with Zero to Mastery final project "smart-brain" - node.js

So I am finishing up a full stack project that was deployed in heroku and connected through github for automatic deployment. The front-end works fine but I am receiving errors both on heroku and the developer tools for Chrome when registering users. The back-end worked fine locally but after deployment I am now receiving an "application error" page. On chrome it kicks out:
Access to fetch at 'https://facial-recognition-machine.herokuapp.com/register' from origin 'https://facerecognitionbrain-sk.herokuapp.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled."
On heroku cli after using "heroku logs -a"
Heroku CLI Error
These are the repositories on my github of the front end and back end for reference.
Front End
Back End
I'm relatively knew to this so thank you in advance for any and all help.

Update: I figured it out from heroku's deployment documentation of Node.js.
I needed a .gitignore file that contained
/node_modules
npm-debug.log
.DS_Store
/*.env
It was also suggested to delete the node_modules and npm install again.

Related

Invalid CORS request: JHipster registry on Azure webapp

I am trying to deploy default Jhipster-registry executable Jar file on Azure webapp. The applications starts and I can see the login page. However, when I put username/password and hit submit, I get error:Invalid CORS request (403 forbidden)
I see that api/authenticate service is called. I also tried to deploy default docker image on azure webapp with docker. It also gives exactly same issue.
Basically I want to deploy Jhipster microservices along with the registry on Azure webapps because I am used to it. I expect that being normal Spring boot web application, it should be possible to achieve this.
Any help is appreciated.
regards,
Venky
Try modifying the "application-dev.yml" file.
Comment all lines related to "CORS"
# CORS is only enabled by default with the "dev" profile
# cors:
# Allow Ionic for JHipster by default (* no longer allowed in Spring Boot 2.4+)
# allowed-origins: 'http://localhost:8100,https://localhost:8100,http://localhost:9000,https://localhost:9000,http://localhost:4200,https://localhost:4200'
# Enable CORS when running in GitHub Codespaces
# allowed-origin-patterns: 'https://*.githubpreview.dev'
# allowed-methods: '*'
# allowed-headers: '*'
# exposed-headers: 'Authorization,Link,X-Total-Count,X-${jhipster.clientApp.name}-alert,X-${jhipster.clientApp.name}-error,X-${jhipster.clientApp.name}-params'
# allow-credentials: true
# max-age: 1800
Or if you prefer include your deploy location in "allowed-origin-patterns:".
In my case I added gitpod.
allowed-origin-patterns: 'https://*.githubpreview.dev,https://*.gitpod.io'

How to import publicly available jelastic manifests from gitlab repositories in the jelastic dashboard?

I am currently transitioning from github to gitlab. Today, my code is present at both those locations. I have a jps manifest on github:
https://github.com/shopozor/services/blob/master/manifest.jps
and the very same manifest on gitlab:
https://gitlab.hidora.com/softozor/services/blob/master/manifest.jps
In the Jelastic dashboard, I am able to load my github manifest. However, I am not able to load my manifest versioned on gitlab:
What is the problem? Do I have to configure something special somewhere? Both manifests are publicly available. Why can't I import the gitlab manifest?
I also tried to use the raw manifest:
https://gitlab.hidora.com/softozor/services/raw/master/manifest.jps
and I've also tried to get the manifest file by means of the gitlab API, without success.
EDIT
I've tried to load this manifest. There we see that I am running a command
wget "${baseUrl}/jelastic/postgres/execCmdScript.sh" -O /var/lib/pgsql/script.sh 2>&1
In the jelastic console, that command raises the error
[07:56:54 Shopozor.cluster:2]: ERROR: cmd [sqldb: 62900].response: {" result": 4109," source": “JEL”," error": “The operation could not be performed. ”," errOut": ""," nodeid": 62900," exitStatus": 4," out": “--2020-03-27 07:56:53-- https://gitlab.hidora.com/softozor/services/raw/install-postgres-in-dedicated-env/jelastic/postgres/execCmdScript.sh\nResolving gitlab.hidora.com (gitlab.hidora.com)... 10.102.1.82\nConnecting to gitlab.hidora.com (gitlab.hidora.com)|10.102.1.82|:443... failed: Connection refused.”}
If I now take a computer which I never authenticated with on gitlab through ssh, and run that very same command, then it works. This is a bit strange, isn't it? What authentication does Jelastic need??? it's all public and available to anyone, except Jelastic?
After some more research, I was finally able to load my manifests from gitlab into jelastic. The problem is probably due to the gitlab configuration. Loading the jps from the gitlab repo doesn't work over https in the settings I have (which I haven't made myself, it's a CI / CD as a service). It works, however, over http.

SuperCluster On Server-Side

While trying to visualize 2 million of markers using the SuperCluster project , i get this error :
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///C:/Users/Ahmed/Desktop/supercluster-master/supercluster-master/test/fixtures/taxi2.geojson. (Reason: CORS request not http).
the Owner of the project told me here that is an XMLHttpRequest Problem and to Solve it i need to serve my page with static server.
So ,since i didn't study node.js before,I searched how node.js projects are used in server.
what i find is that the node.js project needs to contain server.js file which is missed in SuperCluster project.
I am asking how is it possible to Serve this project ?
Solved,
just install http-server and node-static (description here), then put your supercluster project on fixtures (node-static/test/fixtures).
after that run :
node-static> http-server -p 8000
and point your browser to :
http://localhost:8000/test/fixtures/supercluster-master/demo/

Heroku toolbelt error

I'm trying to deploy node.js app on heroku for the first time. As instructed I installed heroku toolbelt but something is wrong.
My machine with windows 10 using heroku toolbelt
Issue:
C:\Users(username)\Downloads\Heroku [master]> heroku login heroku-cli:
Installing Toolbelt v4... ! Heroku client internal error. ! Search for
help at: https://help.heroku.com ! Or report a bug at:
https://github.com/heroku/heroku/issues/new
Error: getaddrinfo: No such host is known.
(SocketError(Excon::Errors::SocketError) Command: heroku login
Version: heroku/toolbelt/3.42.45 (i386-mingw32) ruby/2.1.7 Error
ID: c47aaf8f037042beb25fdceb46cfe78f
More information in C:/Users/courtaks/.heroku/error.log
--------------------------------------------------------------------------------
Solved:
as instructed by the heroku team in this isssue: https://github.com/heroku/heroku/issues/1939
it appears to be a temporary DNS issue.
it's working now.
I didn't do anything except waiting the problem to solve it self. also try changing your dns server, maybe that will work.
--------------------------------------------------------------------------------
Almost 6 months later, I got the exact same issue on the first interaction with heroku, not a good start.
I used the command to verify the installation:
heroku --version
It probably needs some additional data downloading for the first start and installing/preparing heroku-cli.
I am behind a corporate firewall and git + npm are working perfectly fine (after one-time proxy configuration).
The issue resolved automatically after some time along with initial frustration and time consumption. Just shared my experience for any next user landing here until the issue is actually resolved.
Log File extract:
Heroku client internal error. getaddrinfo: No such host is known.
(SocketError)
.
.
.
Heroku client internal error. getaddrinfo: This is
usually a temporary error during hostname resolution and means that
the local server did not receive a response from an authoritative
server. (SocketError)
[cross posted partially on the given heroku git link, same like the original question and answer]
--------------------------------------------------------------------------------
Solved:
as instructed by the heroku team in this isssue: https://github.com/heroku/heroku/issues/1939
it appears to be a temporary DNS issue.
it's working now.
I didn't do anything except waiting the problem to solve it self. also try changing your dns server, maybe that will work.
--------------------------------------------------------------------------------

npm publish to Artifactory results in Failed PUT 302

When I try to npm publish to a private npm repository on Artifactory I get a Failed PUT 302 error. I followed the directions in their video(https://www.youtube.com/watch?v=gyQ0riy3Hk8) and set up a remote repository that points to registry.npmjs.org, another that is the private repo(npm-local), and a virtual repo that aggregates the remote and private repos.
I set up my ~/.npmrc file to use the Artifactory virtual repo and added my credentials. I am able to install public packages fine using this setup. But when I try to publish directly to /npm-local I always get Failed PUT 302 - the repository responds with a generic nginx 302 Found page and npm can't parse the html.
Currently I am using npm#2.13.3 but I even tried reverting back to 1.4.x after reading npm publish to Artifactory not working and had the same issue.
Also I have tried publishing a directory with package.json in it and a tarball - both produce the same 302 error.
After several emails and a phone call I found the fix:
login to artifactoryonline
Goto Admin Tab
Under general settings set the Custom URL Base to: https://YOUR_ACCOUNT_NAME.artifactoryonline.com/YOUR_ACCOUNT_NAME
They said that they are working on having this set for you by default but until then you have to set it manually. Unfortunately it is not documented anywhere and not mentioned in any of the videos that I saw.
NPM v6 is not able to handle the HTTP Status 302. It process this code as successful printing PUT 302 into verbose output. It happens for example, if the Artifactory server expects the connection over https and redirects all the requests from port 80 to 443. NPM v8 handles redirects correctly.

Resources