coding Error

 coding Error

1.
nodemon.ps1        
cannot be loaded because running scripts is disabled on this
system. For more information, see about_Execution_Policies at        
https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ nodemon app.js
+ ~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityExce  
   ption
    + FullyQualifiedErrorId : UnauthorizedAccess


solution:

    Open PowerShell (Run As Administrator)
    Check the current execution policy using this command

    $ Get-ExecutionPolicy
    # You should get 'Restricted'


    Run this command to make it 'Unrestricted'
    $ Set-ExecutionPolicy Unrestricted


2.

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:3000/api/posts. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 200.

 

solution:

app.js (api file)

 
    app.use((req, res, next)=> {
        res.setHeader("Access-Control-Allow-Origin", "*");
        next();
    });
 





Post a Comment (0)
Previous Post Next Post