When go to the url given, something like this: https://master.xyz.amplifyapp.com/, I get 404 page not found. I don't need my own domain for this proof of concept. I also tried https://master.xyz.amplifyapp.com/poc (see my directory structure below). Same result.
Previous steps taken:
The directory was originally created by doing a clone of an empty AWSCodeCommit repository.
I ran create-react-app poc, and when I do npm start in the "poc" directory, it shows fine in the browser with this url: http://localhost:3000/ (Note at bottom of this post, I did the same thing with a NodeJS RESTAPI and got the same result).
This is my directory structure, and from there I did:
git add -all
git commit -m"first checking"
git push
In AWSCodeCommit I can browse the repository and see the code there.
This is the result of connecting CodeCommit to Amplify:
I'm expecting to see the same thing from the provided URL (https://master.xyz.amplifyapp.com/) as I do on my local machine (localhost:3000).
I had one idea. I copied the poc directory up to the main directory, committed, pushed, saw it rebuild/deploy, and tried again, but same result.
NOTE: I have gone through the same exercise with a simple NodeJS REST API. It also gets the "page not found".
Local: http://localhost:8080/api/books
returns: [{"title":"Harry Potter","id":1},{"title":"Twilight","id":2},{"title":"Lorien Legacies","id":3}]
With Amplify:
https://master.xyz.amplifyapp.com/api/books
gives "404 page not found".
I was thinking the problem with the React was that it was a regular React app, and not a Native-React application. But now I'm getting same issue with a simpler nodeJS application, and no idea what to try next.
This is the video that gave me the ideas to get it working, even though I'm not using Cognito. https://www.youtube.com/watch?v=g4qKydnd0vU
The first videos made no mention of installing and running amplify locally.
So I installed amplify on my Windows laptop. Then basically had to run these commands from the windows command prompt:
npm install -g #aws-amplify/cli
amplify configure
amplify init
When I ran the second command, it created another amplify app in AWS. Fortunately, my first project had dashes in it, and this one did not, so they didn't conflict. (I will go back and either delete my originals or try to get them working later).
Many of the videos demonstrate with GitHub, but I was using CodeCommit.
If you get an error in the Build phase that says "The requested URL returned error: 403", that means there is an access issue to your code library. I solved that by changing the "Service role" of my Amplify app to one that I created previously. If you respond with comments to this answer, there's a good chance that I won't have any answers.
amplify configure:
(I used an existing username that I had already created for the first attempts. If you haven't done that, I think you would need to do it so you have the data to paste in for user, access code, and secret.
amplify init:
So this is what I did to get it up and working (for both React and my NodeJS api backend). I have much more reading or watching videos and experimenting ahead to learn more about it. There were many videos that created the apps in the AWS web console, without using the command line "amplify config" and "amplify init" commands. Nobody answered this question for about 4 days, so it seems like maybe it's still new and not so popular yet.
I'm still having a minor issue on the NodeJS api/backend that I will figure out next. For this url: https://master.xyz.amplifyapp.com/api/books/ it returns:
<Error>
<script/>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>1Z3T564T3SSGXJQE</RequestId>
<HostId>mx8RKnqMS1MDe0oOiZ0it3A1sL0bRXHsdZrL5IBuin9S2llrwLFNI+y=</HostId>
</Error>
This is possibly indicative of a "page not found", and needs redirects to solve as discussed in this StackOverflow. The NodeJS code is a simple example that does this:
app.get('/api/books', (req,res)=> {
res.send(books);
});
I did the following which caused another build/deploy, but access denied error is still happening:
git status (I see new Amplify folder)
git add --all
git commit -am"after amplify config/init"
git push
My package.json contains this, among other settings:
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "node index.js",
"prod": "node index.js"
},
Related
So I've been at this for two days now and can't figure it out. I'm trying to deploy a Vue front end and express back end app to Heroku.
In my root folder I have a "public" folder which contains the front end and "server" folder for the back end.
In the root directory's package.json, the start script is
"start": "npm run pull && start npm run f && start npm run b",
"pull": "git pull",
"f": "cd ./public && npm run serve",
"b": "cd ./server && npm run dev"
This works perfectly fine for me to run locally, and even works with heroku locally as well using heroku local web but when I try to actually push to heroku using git push heroku main it doesn't even get past the git pull claiming:
fatal: not a git repository (or any parent up to mount point /)
I've tried simply getting rid of the git pull, but that just leads down a rabbit hole of other errors I've been trying to figure out for days and I'm hoping I'm just being dumb and missing something obvious. Any help would be greatly appreciated.
I'm going to try and list some things I've tried here:
Setting the heroku remote repository heroku git:remote -a heroku-name-here
Didn't change anything, pretty sure I already have this correct
Removing the git pull
Led to heroku not recognizing "start" sh: 1: start: not found
Removing the 'start' after git pull
Led to vue-cli-service not being found
Literally separating the back and front end into 2 separate repositories and 2 separate heroku things
This seemed to get the back end functioning, but the front end didn't seem to work. Unfortunately I don't remember exactly why but can try again if it would be helpful
All 3 comments from here: How to solve vue-cli-service: not found proplem on heroku?
I kind of fixed it kind of. Here's what I did
So I went back to the approach of kind of keeping them separate. I started by getting the server up and running.
In Heroku, I added the buildpack: https://github.com/timanovsky/subdir-heroku-buildpack.git BEFORE the heroku/nodejs buildpack to allow me to use a subdirectory rather than the whole repo
In Heroku settings, I added the config var PROJECT_PATH with the value server - In this case, server was the sub-directory immediately under my root
In vue.config.js of my front end, I changed the outputted build path to go INTO my server folder, using outputDir: path.resolve(__dirname, "../server/front-end")
In mongodb, under "Security" in "Network Access" which can be found towards the left in the navigation, I added the IP address 0.0.0.0/0 which I believe basically lets anyone access it. This might not be the most secure but it works.
Finally, this basically merged all my routes together which causes chaos because if I had a front end route /test-route and a back-end route /test-route it would like break which made sense. So I simply changed my index.js back end routes to go to /api/ instead of / so kind of like this
const mutators = require("./routes/mutators");
app.use(router.use("/api/", mutators));
Then at the end of my index.js file, I added
app.route("/*").get(function(req, res) {
res.sendFile(path.join(__dirname + "/front-end/index.html"));
});
so that front end routes like /test-route would then actually go to the site.
I've spent the last 3 days trying to make a Ubuntu Oracle Cloud VPS a parse server (Yes, I know services like Google Firebase and Back4App but my website consume a lot of requests by a user/hour and I don't have money to spend right now), so I followed this tutorial:
https://dev.to/autodidaktum/how-to-deploy-parse-server-and-parse-dashboard-on-digital-ocean-2021-3o5h
I have followed every step just changing little things like node version (I got the most updated) and didn't create a network domain.
Everything ran "ok" (I had to install some packages and force the parse-server download) but when I reached the "Install Parse Server", the last part of it says to run npm index.js but npm returns with something like: "execute npm run lint", sounded really ok to me but when I ran it, returned me the message:
parse-server-example#1.4.0 lint
eslint --cache ./cloud && eslint --cache index.js && eslint --cache ./spec
and no reach from my browser from "{ip floating address}:1337" (yes, I know that {ip floating address} means the external IP), so I thought I was missing to open a port for access in both areas like inside the server and the Virtual Cloud Network, I opened them (images below) and still no reach.
I let it go and went to the "Install Parse Dashboard" step and started the server, nice message
The dashboard is now available at http://0.0.0.0:4040/
another browser test and still no reach. (obviously, I have tested with externalIp:4040)
The real question is, I did something wrong based on this information?
I am new to google cloud and so I deployed a Nodejs app using the tutorial. Everything worked just fine, here is my file structure (I didn't make the my-nodejs-service folder):
app.yaml
server.js
package.json
I deployed it, everything was fine. So then I tried to make it look like this:
mySite/
server.js
package.json
app.yaml
public/
site contents
I just forked a github repo, deployed it, and it didn't work. By that I mean the site didn't load! I checked the logs, and here was what appeared:
Error: Cannot find module '/workspace/server.js'
at Function.Module._resolveFilename (loader.js:880)
at Function.Module._load (loader.js:725)
at Function.executeUserEntryPoint (internal/modules/run_main.js:72)
"GET / HTTP/1.1" 500
listening on port 3000
It said it couldn't find the server.js file. Was it because I moved the code into the folder? I deployed it on the current working directory being the folder mySite.
package.json (Im only including the scripts part, it other stuff such as the dependencies):
{
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
}
}
Other things I tried:
deploying with app.yaml at the end of the deployment command
Using path.join()
Deploying multiple times
Other info:
I checked the logs and I got this:
"GET / HTTP/1.1" 500 - - "Web browser agent info in here"
Another showed:
i This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application.
And another log said:
!! Process was terminated because the request deadline was exceeded. Please ensure that your HTTP server is listening for requests on 0.0.0.0 and on the PORT environment variable. (Error code 123)
App Engine uses a set of conventions in order to be able to deploy and run code successfully. As you've seen, you can't necessarily take an arbitrary web server solution and deploy it successfully.
Please include more details about specific steps you take. For example, you say "I .. deployed it". It would be useful for you to include the command that you used and any immediate errors that were thrown to provide readers with more context when helping answer your question. It's unclear to me from which directory you attempted to deploy the mySite example but I assume from within mySite.
The first error Cannot find module '/workspace/server.js' results because App Engine builds your code using Cloud Build and Cloud Build (by default) puts your code into a /workspace directory on the build VM. It's not very user-friendly, but it was unable to find server.js and, because your package.json specifies node server.js, it needs it.
Another statement that gives me pause is listening on port 3000. I'm not very familiar with the Node.JS runtime but generally App Engine expects web server's to either listen on port :8080 or provide an environment variable that specifies the port, In your tutorial, this is explained: "process.env.PORT is not set, port 8080". That's probably (!?) another issue.
Lastly, you may (I think you probably don't) need to explicitly reference the public subdirectory (unsure) in order to ensure that it's available at runtime.
I made a website with Vue.js and included Snipcart API for a buy button. I've been trying to deploy it to heroku for 2 days now.
When I enter $ npm run dev it works fine and will display my web app. But for some reason if I do $ node server.js it shows the default Vue welcome page for its webpack ("Welcome to Your Vue App").
I've tried entering "start":"npm run dev" in my package.json but that just results in a forever loading web page. If I enter "start":"node server.js" It results in the same thing as the previous paragraph, it just shows the default Vue welcome page.
I found someone with basically the same issue (How to set up vue(2)-cli app to run with nodejs server) and even tried the same tutorial post but I don't know what that comment/answer is talking about. I am also unsure of how to deploy a static website with a Snipcart API (as a previous user mentioned to me in a previous post).
I am really at a loss as to what to do. Thanks for your time.
Edit: Here is the repo for my app: https://github.com/Taikon/MaroonRiver0
Exactly what I suspected in the comment: You are not building your assets.
Run
npm run build
node server.js
And it should work as expected.
I'm trying to deploy my Django app on Heroku, that makes use of the Blockchain.info API V2 (https://github.com/blockchain/service-my-wallet-v3) and thus needs to run blockchain-wallet-service in the background, which in turn needs Node.js and npm installed.
On localhost, I have used this API successfully by running the service on my own machine, but I'm having trouble deploying to Heroku. Firstly, I assume I will need to run the service on a separate dyno, and that I will need node and npm installed on my instance.
Can someone tell me how to achieve this? I'm new to more advanced features of Heroku, I've tried to use the nodejs buildpack but I doubt this is the correct way. There is also this: https://elements.heroku.com/buttons/kmhouk/service-my-wallet-v3 which I've deployed as a separate app but I've failed to merge it in some way to my Django app.
Any help is much appreciated!
I had this exact same issue, bro, and i finally got some light in the end of the tunnel.
I've cloned the https://github.com/blockchain/service-my-wallet-v3 repository and deployed it to heroku and made some changes on "package.json" file. The problem is that (in heroku) you need to declare the dependencies on package file. I've added these lines:
"dependencies": {
"blockchain-wallet-service": "~0.22.4",
}
and a script to test in the deploy:
"scripts": {
"postinstall": "blockchain-wallet-service -V"
}
Also, by cloning this repository, i needed to add this line too:
"license" : "(ISC OR GPL-3.0)",
hope it works for you